Patterns
Most problems are a small number of ideas in different clothes. Learn the idea once and the problems get easier. They are listed in a sensible order: each one builds on the ones before it.
- 017 problems
Hashing and counting
Trade memory for speed by remembering what you have already seen.
- 022 problems
Prefix sums
Precompute running totals so range questions become subtraction.
- 035 problems
Two pointers
Walk two positions through the data instead of nesting loops.
- 044 problems
Sliding window
Keep a moving range valid while you scan once.
- 059 problems
Stack
Last in, first out. Matching, nesting and next-greater problems.
- 065 problems
Binary search
Halve the search space whenever the answer is monotonic.
- 076 problems
Linked list
Pointer manipulation, fast and slow pointers, in-place rewiring.
- 086 problems
Intervals
Sort by start, then sweep and merge.
- 0914 problems
Trees and recursion
Depth-first traversal and recursive structure.
- 105 problems
Breadth-first search
Level by level and shortest path on unweighted graphs.
- 114 problems
Backtracking
Build choices one at a time and undo them when they fail.
- 128 problems
Graph traversal
Connectivity, components and cycles.
- 134 problems
Topological sort
Order tasks that depend on each other.
- 141 problems
Union-find
Track which items belong to the same group.
- 153 problems
Shortest paths
Weighted graphs with Dijkstra and its relatives.
- 164 problems
Trie
Prefix trees for words and autocomplete.
- 178 problems
Heap and top-K
Keep the best K items without sorting everything.
- 182 problems
Greedy
Take the locally best step and prove it is safe.
- 1915 problems
Dynamic programming
Reuse answers to overlapping subproblems.
- 207 problems
Bits and math
Bit tricks and number properties.
- 2110 problems
Matrix and parsing
Grids, simulation and careful string handling.
- 2224 problems
Design a data structure
Build a class with the right operations and complexity.