Interview prep
LeetCode Pattern Guide
Skip the random grind. These 7 patterns cover the vast majority of what shows up in real interviews. Learn to recognize them fast — that's the actual skill.
Two Pointers
Compare or converge values from both ends of an array.
Sliding Window
Find the best contiguous subarray or substring without recalculating from scratch.
Fast & Slow Pointers
Two pointers moving at different speeds reveal hidden structure.
Binary Search
Cut the search space in half every step instead of scanning one by one.
DFS + BFS
Traverse trees and graphs. DFS goes deep, BFS goes wide.
Dynamic Programming
Break a hard problem into smaller repeated decisions and store results.
Backtracking
Explore all valid options by choosing, recursing, and undoing.
Universal guide
The Cheat Sheet
Use this to identify patterns fast and survive any coding screen.
- array + pair sum / compare ends→ Two Pointers
- substring / subarray / longest / shortest→ Sliding Window
- cycle / middle / linked list→ Fast & Slow Pointers
- sorted / monotonic / minimum viable value→ Binary Search
- tree / graph / visit nodes / islands→ DFS or BFS
- overlapping subproblems / count ways / min cost→ Dynamic Programming
- generate all combinations / paths / permutations→ Backtracking
- 1.Say the brute force first — always
- 2.Identify the repeated work or exploitable structure
- 3.Name the pattern out loud before you code
- 4.Explain why the pattern fits this problem
- 5.Code the simplest correct version
- 6.Test with a small example manually before submitting
- ✗Jumping into coding before understanding the problem
- ✗Not clarifying input size, edge cases, or output format
- ✗Off-by-one errors in binary search boundaries
- ✗Forgetting the visited set in graph problems
- ✗Messing up the window shrink condition in sliding window
- ✗Panicking on DP because the state wasn't defined first
- ✗Going silent when stuck instead of narrating your thinking
Interview rule: If you can identify the pattern in the first 2 minutes, the problem becomes dramatically easier. The real skill is pattern recognition — not memorizing 500 solutions.