Reqflow
Stack & Queue·Beginner

Stack: Push, Pop, Peek

Time O(1) per opSpace O(n)
·

A stack is a Last-In First-Out (LIFO) data structure with three core operations: push (add to top), pop (remove from top), and peek (read top without removing). All three run in O(1). Stacks appear everywhere: function call frames, undo history, expression parsing, DFS traversal, and balanced bracket checking.

Example: Watch push, pop, and peek operations on a live stack.

When to use this

See also

← All algorithms