A roadmap for data structures and algorithms
The 150 problems fall into 18 topics, drawn as 6 lines like a transit map. Ride each line from its first station, and change lines where a topic builds on one from another line.
Foundations
The three basic containers, in order: an array, then one end of it (a stack), then nodes joined by pointers.
- Arrays & Hashing9 problems
- Stack6 problems
- Linked List11 problems
Search & scan
Two indexes over an array. A window is two pointers moving the same way, and binary search halves the range between them.
- Arrays & Hashing9 problems
- Two Pointers5 problems
- Sliding Window6 problems
- Binary Search7 problems
Trees
A tree node is a list node with two next pointers. A trie is a tree keyed by letters, and a heap is a tree packed into an array, which shortest paths need.
- Linked List11 problems
- Trees15 problems
- Tries3 problems
- Heap / Priority Queue7 problems
- Advanced Graphs6 problems
Graphs
Backtracking is a depth-first walk over a tree of choices. Graphs are the same walk when nodes can lead back, and weighted graphs arrive where the heap does.
- Trees15 problems
- Backtracking10 problems
- Graphs13 problems
- Advanced Graphs6 problems
Optimization
Dynamic programming is backtracking that remembers answers. Greedy is the case where one choice is always safe, and intervals are sorted, then swept greedily.
- Backtracking10 problems
- 1-D Dynamic Programming12 problems
- 2-D Dynamic Programming11 problems
- Greedy8 problems
- Intervals6 problems
Math & bits
It needs nothing past arrays, so it branches off the first station.
- Arrays & Hashing9 problems
- Math & Geometry8 problems
- Bit Manipulation7 problems