Interactive algorithm visualizations
Every trace is generated from a real execution and verified before it ships. No account needed.
- Binary Search — Easy, Binary Search: The canonical divide-and-conquer search. Maintain a window and halve it each probe, discarding the half that cannot hold the target.
- Valid Parentheses — Easy, Stack: The canonical stack problem. The top of the stack is always the bracket that must close next; the string is valid only if the stack empties.
- Spiral Matrix — Medium, Matrix: Walk a 2D grid in spiral order by shrinking four boundaries inward. Teaches careful boundary management on a matrix.
- Unique Paths — Medium, Dynamic Programming: Fill a DP table where each cell is the sum of the cell above and to the left. The classic 2D DP recurrence.
- Range Sum Query — Easy, Prefix Sum: Precompute cumulative sums so any range sum is a single subtraction. Turns O(n) queries into O(1).
- Number of Recent Calls — Easy, Queue: A FIFO queue of timestamps; evict from the front anything outside the window. Shows how a queue tracks a sliding time range.
- Sliding Window Maximum — Hard, Monotonic Deque: A deque of indices kept decreasing; the front is always the window max. The definitive monotonic-deque problem.
- Design Circular Queue — Medium, Ring Buffer: A fixed-capacity buffer with head/rear indices that wrap around. Enqueue and dequeue in O(1) without shifting.
- Binary Tree Inorder — Easy, Tree: Inorder traversal of a BST visits values in sorted order. Shows how recursion threads left, node, right.
- Build a Min-Heap — Medium, Heap: Insert values one by one, sifting each up until the parent is smaller. The heap array is a complete binary tree.
- Fibonacci (Recursion Tree) — Easy, Recursion: Naive fib(n) - the call tree is the lesson: exponential repeated work that memoization later collapses.
- Reverse Linked List — Easy, Linked List: Flip every next-pointer in one pass. The fundamental pointer-rewiring exercise.
- Two Sum — Easy, Hash Map: Store each value's index in a map and look up the complement. Trades space for O(n) time.
- Breadth-First Search — Medium, Graph: Explore a graph in layers using a frontier queue. Visits nodes in non-decreasing distance from the source.
- Connected Components — Medium, Union-Find: Merge elements into disjoint sets and count the roots. Near-constant per operation with path compression.
- Implement Trie — Medium, Trie: Insert words into a prefix tree, then test a prefix by walking character edges. Shared prefixes share nodes.