Browse by topic
01Array and string patterns
Two pointers
Use order to eliminate impossible candidates.
Sliding window
Reuse work across adjacent ranges.
Prefix sums
Turn range calculations into subtraction.
Intervals
Sort first, then reason about overlap.
02Data structures
Stacks and monotonic stacks
Remember unresolved candidates.
Linked lists
Track ownership of every link before rewriting it.
Binary search
Search a monotonic answer space.
Heaps and top K
Maintain only the candidates you need.
Tries
Share prefixes across strings.
03Trees, graphs and optimization
Depth-first search
Explore a branch while preserving traversal state.
Breadth-first search
Explore unweighted distance in layers.
Topological sort
Order work constrained by dependencies.
Backtracking
Explore choices and undo their effects.
Dynamic programming
Reuse solutions to repeated subproblems.
Greedy reasoning
Prove a local decision preserves an optimal solution.