The 8 patterns that cover most problems
If you learn to spot these, you can solve the large majority of interview questions. Master them in this order.
| Pattern | Use it when | Classic example |
|---|---|---|
| 1 Two Pointers | A sorted array, or you compare from both ends | Pair with target sum |
| 2 Sliding Window | Longest / shortest subarray or substring | Longest substring without repeats |
| 3 Hashing | You need fast lookups or counts | Two Sum, group anagrams |
| 4 Binary Search | Sorted data, or "find the smallest X that works" | Search in rotated array |
| 5 Stacks / Queues | Matching, nesting, or next-greater problems | Valid parentheses |
| 6 Trees / BFS & DFS | Hierarchies, levels, or "explore everything" | Level-order traversal |
| 7 Recursion / Backtracking | Try all combinations, undo, try again | Subsets, permutations |
| 8 Dynamic Programming | Overlapping subproblems, "min / max / count ways" | Climbing stairs, coin change |
An 8-week plan that won't burn you out
Weeks 1-2: Arrays, strings, hashing, two pointers, sliding window. These show up everywhere. ~2 problems/day.
Weeks 3-4: Binary search, stacks, queues, linked lists. Learn to reason about pointers calmly.
Weeks 5-6: Trees, BFS, DFS, recursion. Draw the tree on paper before you code.
Weeks 7-8: Backtracking and gentle DP. Do not fear DP, start with the classic 5 and build intuition.
How to actually practice (the part most people skip)
- Try for 20-30 minutes before looking at the solution. The struggle is where the learning happens.
- When stuck, read only a hint, not the full answer. Then close it and solve it yourself.
- Keep a "patterns notebook". For each problem write: what pattern, what tipped you off, the key trick. Review it weekly.
- Re-solve problems you failed, a few days later, from a blank editor. If you can't, you didn't learn it yet.
- Explain your solution out loud. If you can teach it, you understand it. This is also literally what interviews test.
Free places to practice
- LeetCode study plans - start with "LeetCode 75" or "Top Interview 150".
- NeetCode 150 - the same core problems, grouped by pattern, with clear videos.
- HackerRank - gentle on-ramp if LeetCode feels intimidating.
- VisuAlgo - see the data structures and algorithms animate. Great for building intuition.
Remember: consistency beats intensity. 2 problems a day for 8 weeks is ~112 problems, more than enough to walk into interviews with real confidence.
🌱 New to DSA? Read this first
You do not need to be "good at math". You need to recognize patterns and practice a little every day. Aim for 1 to 2 problems a day, not 20 on Sunday. Quality over quantity, always. Stuck on a problem? Tap ✦ Ask AI to get a hint without spoiling the whole solution.