Don't Memorize Solutions
Think of learning to cook. A beginner memorizes recipes word-for-word. An experienced chef recognizes techniques — sautéing, braising, emulsifying — and applies them to any ingredient. Algorithmic interviews reward the chef, not the recipe-memorizer.
Most interview problems are variations of about 15 core patterns. If you recognize the pattern, the solution structure becomes obvious and the code almost writes itself. Trying to memorize hundreds of individual LeetCode solutions is both impossible and counterproductive — you will always encounter a problem you haven't seen before.
The "Is it...?" Checklist
When you see a new problem, run through this mental checklist before writing a single line of code:
- Array/String with a contiguous subrange? → Sliding Window
- Sorted array, pair-finding, or symmetry check? → Two Pointers
- Locally optimal choices lead to global optimum? → Greedy
- All permutations, subsets, or constraint-satisfaction? → Backtracking
- Tasks with dependencies or ordering constraints? → Topological Sort
- Overlapping subproblems where you need the global optimum? → Dynamic Programming
The five patterns covered in this lesson — Sliding Window, Two Pointers, Greedy, Backtracking, and Topological Sort — collectively solve the majority of array, string, and graph problems you will encounter in technical interviews.
How to Use This Lesson
For each pattern, the goal is to internalize three things: what kind of problem triggers it, how the mechanism works, and what the code skeleton looks like. Once those three are locked in, you can adapt to any variation.