Stack
Only the top is reachable. The last thing down is the first thing up.
Decision · step 5 of 10Stack: Push, pop, peek
pop returns 9: the most recently pushed item leaves first.
What you will see
Items drop onto the TOP and lift off the TOP; nothing below moves.
Cost
| push | O(1) |
|---|---|
| pop | O(1) |
| peek | O(1) |
| search | O(n) |
| 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.
Before this
Leads to
Topics that need this one first.