Interview Patterns and a Practice Plan
Most interview questions are variations of a few patterns. Learn to recognise them:
Interviews test how you approach unfamiliar problems: do you clarify, start simple, then improve? A steady plan - a few problems a day, grouped by pattern, explained out loud - builds that skill far better than cramming solutions.
- Hash map - "find pairs", "count", "seen before?" (Two Sum, anagrams)
- Two pointers - sorted arrays, pairs, reversing, removing duplicates
- Sliding window - "longest/shortest subarray or substring with..."
- Binary search - sorted data, or "smallest value that works"
- Stack - brackets, "next greater", undo
- BFS / DFS - grids, trees, networks, "fewest steps"
- Heap - "top k", "k-th largest", merging
- DP - "number of ways", "min/max cost" with choices
- Backtracking - "all combinations / permutations"
How to answer in an interview
- Repeat the question in your own words and ask about edge cases (empty input? duplicates? negative numbers?).
- Say a simple solution first, even if slow, and its Big-O.
- Improve it with a pattern and explain the trade-off.
- Write clean code with good names, talking as you go.
- Test with a small example and an edge case, line by line.
A 6-week practice plan (about 1 hour a day)
- Week 1: arrays, strings, hashing - 15 easy problems
- Week 2: two pointers, sliding window, prefix sums
- Week 3: stacks, queues, linked lists
- Week 4: binary search, sorting, recursion
- Week 5: trees, heaps, graphs (BFS/DFS)
- Week 6: DP and backtracking, plus timed mock interviews
Example
Practise on sites like LeetCode, HackerRank or GeeksforGeeks. Solve each problem yourself first for 20-30 minutes before reading a solution, and revisit problems a week later - repeating is how patterns stick.
Key points
- Clarify, brute force, then optimise and state Big-O.
- Practise by pattern: hashing, two pointers, BFS/DFS, DP.
- Explain your thinking out loud.
📝 Test yourself
1. A question says 'longest substring with at most 2 different letters'. Which pattern?
2. What should you do first in an interview?
3. 'Find the k most frequent words' suggests...
