12 ms·
Doesn't this preserve the original order? The deque is used as a queue, first in first out. In order for the elements to be reversed it should be used as a stac
by zvolsky 3y ago
Doesn't this preserve the original order? The deque is used as a queue, first in first out. In order for the elements to be reversed it should be used as a stack.
- klyrs 3y agoPushing to back... q={v[0]} q={v[0],v[1]} q={v[0],v[1],v[2]} Popping from front... v[0] = v[0]; q={v[1],v[2]} ... Yeah, so clever it's doubly reversed