Module 1 · Complexity and how to think out loud Lesson 2 of 15
The pattern-first method
Interviews repeat patterns far more than they repeat problems. Naming the pattern is how a new question becomes a familiar one.
The concept
Interview questions are not 500 different problems; they are about a dozen patterns wearing different clothes. Two pointers, sliding window, hash map, binary search, recursion, breadth-first search, and a handful more. Recognising the pattern is most of the work — the code is then short.
The signals are in the question. "Sorted array" suggests two pointers or binary search. "Subarray" or "longest substring" suggests a window. "Have you seen this before", "count the frequency" or "find the pair" suggests a hash map. "Minimum number of steps in a grid" suggests BFS. Say which pattern you are considering and why — that sentence is worth more than typing.
Signals in the question -> pattern:
"sorted array", "pair sum" -> two pointers / binary search
"subarray", "longest substring" -> sliding window
"count frequency", "have I seen" -> hash map / set
"minimum steps in a grid" -> BFS
Name the pattern and WHY before you type a line.Common mistakes
The mistake is starting to type while you are still deciding. Spend the first two minutes reading the example carefully and naming the pattern; the interviewer is scoring your approach, and a wrong approach written quickly scores nothing.
Worked example
"Find two numbers that add to a target" and "find a subarray with a given sum" are both the same two-pointer / hash-map family — recognising that is the whole skill.
Your practice task
Take ten problems you have solved and write the pattern name beside each one.
Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.
Key takeaway
Interview questions are not 500 different problems; they are about a dozen patterns wearing different clothes.
Keep your place in this course
A free account saves which lessons you have finished and unlocks the certificate. The lesson itself stays free to read.
Create free account or sign inCourse complete
You finished every lesson.
Your certificate is ready, and the projects you built are the proof to attach to an application.
Almost there
15 lessons left of 15
Finish every lesson to unlock the certificate. Each one ends in a practice task — do them and the final project brief writes itself.