← Back to the stacks page
Plain LIFO Stack
Push and pop from one end. Anything with "most recent first" semantics — undo, nesting, backtracking — is a stack.
What to know
- Matching brackets: push openers, pop and compare on closers.
- Iterative DFS replaces the call stack with an explicit one.
- Backed by a dynamic array (fast) or linked list (no resize).
In the wild: Call stacks, browser history, undo systems, JSON/XML parsers.
Algorithms to reach for
Valid parentheses matching
O(n)Check nesting of brackets/tags (LeetCode 20)
Iterative DFS
O(V + E)Depth-first traversal without recursion limits
Undo/redo pair of stacks
O(1) per opEditor history navigation
Practice problems — with full guides
Each problem has its own page: progressive hints, how to approach it, and the full solution.