Learn the patterns behind coding interview problems.
Most interview problems are variations on a few dozen ideas. Learn to spot them, and you can solve problems you haven't seen before.
- Understand data structuresArrays, hash maps, trees, graphs, and more: operations, costs, and working implementations.
- Learn the patterns32 short chapters on the techniques behind most interview problems.
- Browse every problemAll 4,072 problems with a finished solution you can read, flip through, and run.
- Follow a walkthrough29 problems explained step by step, from the slow solution to the fast one.
Also here: system design labs for an LRU cache and a file system.
How every lesson works
Write the slow solution that obviously works. Find the repeated work that makes it slow. Then remove only that work. Here is one problem, solved with a sliding window. Press Step to watch it run:
Shortest subarray of [2, 3, 1, 2, 4, 3] with a sum of at least 7
- 2
- 3
- 1
- 2
- 4
- 3
Done. The shortest subarray is [4, 3], length 2.
Sum 7Best 2
How to study
- Write the slow solution before you read on. Stop after the problem statement and get something that works.
- Write the fast solution yourself. Once the lesson shows the repeated work, try to remove it before you read how.
- Solve it again in a few days. Start from a blank page. Recognizing a solution is not the same as writing it.
To check whether you've learned the pattern or only remember one problem, try the transfer exercises.