Deque
Insert and remove at both ends in O(1).
Decision · step 5 of 10Deque: Push and pop at both ends
pop-back returns 3, the item at the back. The other end is untouched. Size 2.
What you will see
Items enter and leave from either end; used by sliding-window maximum.
Cost
| push front | O(1) |
|---|---|
| push back | O(1) |
| pop front | O(1) |
| pop back | O(1) |
| Space | O(n) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.
Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.
Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.