Practice
Solve it yourself
178 problems in 22 patterns. Watch a pattern run in its session, then solve the problems that use it. Every problem says what to solve, its limits and examples, and the complexity to aim for, hidden until you want it.
How it works
- 1. Clone optimal-round. Each problem is one file with an empty function.
- 2. Fill it in by hand. No AI: a solution you did not work out teaches you nothing.
- 3. Run
./practice c 009to check correctness and speed, then mark it solved here.
Patterns with a visual
Start here: each one has an interactive session that shows the pattern working.
- Arrays & Hashing19
9 easy9 medium1 hard
Visual: Hash map: group anagrams
0 of 19 solved
- Two Pointers15
6 easy8 medium1 hard
Visual: Two pointers: most water
0 of 15 solved
- Sliding Window6
1 easy3 medium2 hard
Visual: Sliding window
0 of 6 solved
- Stack9
2 easy6 medium1 hard
Visual: Monotonic stack: next warmer day
0 of 9 solved
- Binary Search9
2 easy5 medium2 hard
Visual: Binary search
0 of 9 solved
- Linked List10
5 easy4 medium1 hard
Visual: Fast and slow pointers
0 of 10 solved
- Trees13
5 easy6 medium2 hard
Visual: Trees: let the children answer first
0 of 13 solved
- Graphs8
7 medium1 hard
Visual: BFS vs DFS
0 of 8 solved
- Dynamic Programming18
3 easy13 medium2 hard
Visual: Dynamic programming: coin change
0 of 18 solved
- Backtracking10
9 medium1 hard
Visual: Backtracking: choose, explore, undo
0 of 10 solved
- Intervals & Greedy6
6 medium
Visual: Merge overlapping intervals
0 of 6 solved
- Heap / Priority Queue5
1 easy3 medium1 hard
Visual: Heap: top k of a stream
0 of 5 solved
- Tries3
2 medium1 hard
Visual: Trie: prefix lookups
0 of 3 solved
- Queues & Design5
2 easy3 medium
Visual: LRU cache
0 of 5 solved
- Union-Find4
4 medium
Visual: Union-find: connected groups
0 of 4 solved
- Advanced Graphs5
4 medium1 hard
Visual: Dijkstra: shortest paths
0 of 5 solved
- Prefix Sum4
2 easy2 medium
Visual: Prefix sums: range sums in O(1)
0 of 4 solved
More patterns
Problems and a written explainer in optimal-round; the visual is still to come.