Coding Interview Prep: What Gets Scored and a 6-Week Plan
The four signals coding interviewers score, the patterns behind most problems, complexities people get wrong, and a week-by-week study plan.
By Redbison Dev · · Updated · 6 min read

Two candidates get the same problem: find the length of the longest substring without repeating characters. The first writes a correct O(n) sliding window in eight minutes, in silence, and says "done". The second talks through a brute force, explains why it is O(n²), spots the sliding window, codes it in fifteen minutes, then traces "abba" by hand and fixes an off-by-one before the interviewer mentions it. In many debriefs the second candidate gets the stronger score.
Coding interviews reward a visible process as much as a correct answer. This guide covers what the round measures, a study plan by week, the patterns worth learning, and the mistakes that sink otherwise capable engineers. Track your topics in the Coding Interview Prep Checklist as you work through them.
What interviewers score
Most coding rubrics, whatever they are called, measure four things:
| Signal | What it looks like | What loses it |
|---|---|---|
| Problem solving | Clarifies inputs, finds an approach, improves it | Jumping into code on a misread problem |
| Communication | Explains the plan before coding, thinks aloud | Long silences, no plan stated |
| Code quality | Readable names, small helpers, correct edge cases | Clever one-liners nobody can follow |
| Verification | Traces an example and an edge case unprompted | Saying "done" without testing |
An optimal solution helps, but it is one input. A clean brute force plus a clear explanation of the faster approach can pass. A fast, silent, buggy solution often does not.
The seven-step method in practice
The checklist page lists seven steps. In a 45 minute round they compress to something like this:
- Understand (2 to 3 min). Restate the problem. Ask about input size, value ranges, duplicates, empty input, and what to return when there is no answer.
- Examples (2 min). Work one normal case and one edge case by hand.
- Break it down (2 min). Name the pattern you think applies and why.
- Plan (3 to 5 min). Describe the algorithm and its time and space complexity before writing code. Get a nod from the interviewer.
- Code (15 to 20 min). Write it cleanly, narrating as you go.
- Test (5 min). Trace your own example through the code, then the edge case.
- Optimize (remaining time). Discuss what you would improve and the trade-offs.
The step people skip is 4. Coding before agreeing on a plan is how you end up rewriting half your solution with ten minutes left.
Patterns that cover most problems
Interview problems are drawn from a fairly small set of patterns. Learn to recognise the trigger in the problem statement:
| If the problem says... | Reach for | Typical complexity |
|---|---|---|
| Sorted array, find a pair or triplet | Two pointers | O(n) after sorting |
| Longest or shortest contiguous subarray or substring | Sliding window | O(n) |
| Sorted input, or "minimum value that satisfies X" | Binary search (including on the answer) | O(log n) per search |
| Top k, k-th largest, merge k lists | Heap | O(n log k) |
| Shortest path, equal edge weights | BFS | O(V + E) |
| Connected regions, islands, all paths | DFS | O(V + E) |
| Order with dependencies | Topological sort | O(V + E) |
| Count the ways, min or max cost over choices | Dynamic programming | Number of states times work per state |
| All combinations or permutations | Backtracking | Exponential |
Complexities you must not get wrong
Interviewers notice when a candidate states a complexity confidently and incorrectly. The usual offenders:
- Quicksort is O(n log n) on average and O(n²) in the worst case. Merge sort is O(n log n) in all cases but uses O(n) extra space.
- Hash map operations are O(1) on average and O(n) in the worst case, when many keys collide.
- Building a heap from n items is O(n). Inserting n items one at a time is O(n log n).
- Binary search is O(log n), but only on sorted data. Sorting first costs O(n log n).
- String concatenation in a loop can be O(n²) in languages with immutable strings. Use a list and join.
- Recursion uses stack space. A DFS over a tree of height h needs O(h) space, which is O(n) for a skewed tree.
A quick self-check: say the complexity, then say what the input size limit implies. With n up to 100,000, O(n²) is ten billion operations, which is too slow; O(n log n) is about 1.7 million, which is fine.
Worked example: two sum, three ways
"Given an array and a target, return the indices of two numbers that add up to the target."
def two_sum_brute(a, target):
# 1. Brute force: O(n^2) time, O(1) space
n = len(a)
for i in range(n):
for j in range(i + 1, n):
if a[i] + a[j] == target:
return [i, j]
# 2. Sort plus two pointers: O(n log n) time, but sorting loses
# the original indices unless you sort (value, index) pairs.
def two_sum(a, target):
# 3. Hash map: O(n) time, O(n) space
seen = {}
for i, x in enumerate(a):
if target - x in seen:
return [seen[target - x], i]
seen[x] = i
Saying all three out loud, with the trade-off for each, takes about a minute and shows the interviewer the full range of your thinking. Then code the hash map version. Test it on [3, 3] with target 6: checking before inserting is what makes duplicates work.
A study plan by week
Most working engineers need four to eight weeks at 8 to 10 hours a week. A six-week version:
- Week 1: Arrays, strings, hash tables. Two pointers and sliding window. Get the seven steps into your habits from the first problem.
- Week 2: Binary search (including on the answer space), linked lists, stacks and queues.
- Week 3: Trees: traversals, BST operations, lowest common ancestor. Heaps.
- Week 4: Graphs: BFS, DFS, topological sort, union-find. Dijkstra for weighted paths.
- Week 5: Dynamic programming and backtracking. These take the longest, so do not squeeze them.
- Week 6: Mixed problems under a 45 minute timer, plus at least three mock interviews with another person.
Tick a topic in the checklist only when you can solve a new problem of that type without hints. The percentage is for you, so keep it honest. Revisit any problem you failed after three or four days and solve it again from a blank file.
Common mistakes
Not asking clarifying questions. Input constraints change the right answer. Ask.
Coding in silence. The interviewer cannot score thinking they cannot hear.
Ignoring the edge cases you listed. Empty input, one element, all duplicates, negative numbers, integer overflow.
Grinding one topic. Three hundred array problems will not help when the question is a graph.
Not testing. Trace your code with a real example before you say you are finished. Finding your own bug is a positive signal; having it found for you is a negative one.
Putting it together
Use a stopwatch for every practice problem, because time pressure changes how you think. Keep a short log of each problem: pattern, mistakes, time taken. Once coding feels steady, start on the System Design Interview Framework if your loop includes it, and prepare behavioral stories with the STAR answer builder. Candidates who prepare for all three rounds usually do better than those who spend every hour on algorithms.
Frequently asked questions
What do coding interviewers look for?
Most coding interview rubrics score four signals: problem solving, communication, code quality and verification. Interviewers want to see a candidate clarify inputs, explain a plan before coding, think aloud, write readable code with correct edge cases, and trace an example unprompted. A clean brute force with a clear explanation of the faster approach can pass, while a fast, silent, buggy solution often does not.
What are the most common coding interview patterns?
Coding interview problems come from a fairly small set of patterns: two pointers for pairs in sorted arrays, sliding window for contiguous substrings, binary search, heaps for top k, BFS for shortest paths with equal weights, DFS for connected regions, topological sort for dependencies, dynamic programming for counting or optimising over choices, and backtracking for combinations and permutations.
How do you solve two sum in O(n) time?
Solve two sum in O(n) time with a hash map. Loop through the array once, and for each value check whether target minus that value is already in the map; if it is, return both indices, otherwise store the value with its index. Checking before inserting is what makes duplicates like [3, 3] with target 6 work. It uses O(n) space.
What is the time complexity of building a heap?
Building a heap from n items at once is O(n), while inserting n items one at a time is O(n log n). Other complexities candidates often get wrong: quicksort is O(n log n) on average but O(n²) in the worst case, and hash map operations are O(1) on average but O(n) in the worst case when many keys collide.
How should I spend time in a 45 minute coding interview?
In a 45 minute coding interview, spend 2 to 3 minutes understanding the problem, 2 minutes on examples, 2 minutes naming a pattern, 3 to 5 minutes planning with complexity, 15 to 20 minutes coding, 5 minutes testing, and the rest discussing optimisations. The step people skip is planning, which is how candidates end up rewriting half their solution late.
Sources and further reading
- Quicksort, The Computer Journal. C. A. R. Hoare, 1962.
- A note on two problems in connexion with graphs, Numerische Mathematik. Dijkstra's 1959 shortest-path algorithm.
- Algorithm 245: Treesort, Communications of the ACM. Floyd's bottom-up heap construction.
- The Art of Computer Programming, Stanford University (Donald Knuth). Volume 3 covers sorting and searching.
Open the Coding Interview Prep Checklist
More Interview Prep
Every tool in the Interview Prep section, free and in your browser.