Train the pattern here.
Practice on LeetCode.
We are not another problem archive. We compress the gap between I read the problem and I see the trick from hours into minutes — with interactive animations that teach the mental model, not the syntax.
family · 3 sub-patterns
Two Pointers
Two indices moving over the same sequence to maintain an invariant — converging, fast/slow, sliding window.
converging · fast-slow · sliding
single
Binary Search Variants
Boundary conditions are the field's largest unsolved teaching problem.
3 variants · O(log n)
single
Backtracking
Decision-tree expansion — uniquely suited to animation.
branching state machine
single
Monotonic Stack
Stack-state transitions are invisible in code, dramatic in animation. The stack is the protagonist.
next-greater · histogram
phase 2
BFS / DFS on Gr DFS
A queue gives breadth, a stack gives depth — same algorithm, two traversal orders.
queue · stack · flood fill
family · 3 sub-patterns
Heap & Priority Queue
Cheap access to the extreme — min or max — while everything else stays loosely ordered. A family of three sub-patterns: top-k, two heaps, k-way merge.
top-k · two-heaps · k-way-merge
phase 2
Tree Traversal
Every traversal visits every node once — only when relative to children's recursion differs.
preorder · inorder · postorder · level
phase 2
Linked List Manipulation
Three pointers — prev, curr, next — let you rewrite a list in place without losing the tail.
reverse · merge · reorder
family · 5 sub-patterns
Dynamic Programming
A table fills itself, one cell at a time — each entry composed from a constant number of earlier ones. A family of five sub-patterns.
1-d · 2-d · knapsack · interval · state-machine
single · phase 3
Union Find
Maintain a partition of N elements into disjoint components — merge two components in near-constant time, with the forest flattening itself on every query.
connected components · O(α(N))
single · phase 3
Trie
Store a set of strings on a tree of characters — words that share a prefix share a path, and a single 'end-of-word' flag separates stored words from in-flight prefixes.
prefix queries · autocomplete · word-search
single · phase 3
Topological Sort
Linearize a directed acyclic graph so every edge points left-to-right — each node enters the order only after every prerequisite has already left.
Kahn's algorithm · O(V + E) · cycle detection
family · 4 sub-patterns
Prefix Sum
Pay O(N) once to amortize every range query to O(1) — and flip it inside-out for cheap range updates. A family of four sub-patterns.
1-d · 2-d · difference · hash-map
family · 4 sub-patterns
Shortest Path
Find the shortest route from a source — the mechanism splits by what the edges carry. BFS for uniform costs, Dijkstra for non-negative, Bellman-Ford for negatives, Floyd-Warshall for all pairs.
BFS · Dijkstra · Bellman-Ford · Floyd-Warshall
single
Merge Intervals
Sort by start, then sweep — each interval either extends the current merge or commits it and starts a new one. The whole pattern lives in that one comparison.
sort + linear sweep · O(N log N)
single
Bit Manipulation
Treat integers as their bits, not their values — XOR a number against itself to zero it, against zero to keep it. The trick is recognizing when a problem has a hidden bit-level structure.
XOR · bit mask · O(N)
family · 2 sub-patterns
Cyclic Sort
When values live in [0, N] or [1, N], the index is the pointer — each element already knows where it belongs. Swap to home, or sign-flip to mark seen, and a whole family of missing/duplicate problems collapses to O(N) and O(1) space.
index-as-pointer · O(N)