Coding Interview Tips: How to Prepare and How to Think Out Loud
A practical guide to coding interviews: the 45-minute structure, the problem patterns that cover most questions, how to communicate while coding, an 8-week prep plan and common mistakes.
Key takeaways
- Interviewers grade your process as much as your final code: clarifying, planning, communicating, testing.
- Use a fixed 45-minute structure: clarify, brute force, optimize, code, test, analyze complexity.
- About a dozen problem patterns cover most interview questions. Learn patterns, not individual problems.
- Think out loud the whole time. Ten silent minutes followed by a perfect solution scores lower than a clear path to a good one.
- Practice with a timer and out loud, 2–3 problems a day, for 6–8 weeks before big-tech interviews.
Contents
The most important coding interview tip is that the interviewer is grading your process, not just your final answer. Clarify the problem, state a brute-force approach, improve it, then code in small steps while explaining your reasoning, and finish by testing with examples and stating the complexity. Prepare by learning the dozen problem patterns that cover most questions and practicing them out loud with a timer.
What interviewers actually evaluate
| Area | What they look for |
|---|---|
| Problem solving | Breaks the problem down, considers several approaches, finds an efficient one |
| Coding | Correct, readable code; good names; sensible structure |
| Communication | Explains reasoning before and during coding; responds well to hints |
| Testing | Checks normal and edge cases; finds and fixes own bugs |
| Complexity | States time and space complexity correctly and discusses trade-offs |
Notice that only one row is about getting the code right. Candidates who solve the problem silently often score lower than candidates who explain a slightly less optimal solution clearly.
The 45-minute structure
Most coding rounds last 45–60 minutes, with the first and last few minutes for introductions and your questions. Use a fixed structure so you never wonder what to do next:
Recommended time budget for one medium problem.
Step 1: Clarify before coding
Restate the problem in your own words and ask about the input:
- How large can the input be? (This tells you which complexities are acceptable.)
- Can it be empty? Contain duplicates? Negative numbers? Is it sorted?
- What should happen with invalid input?
- Is there a memory limit?
Write one normal example and one edge case. Two minutes here prevent the most expensive mistake: solving the wrong problem.
Step 2: Start with brute force
“The simplest approach is to compare every pair, which is O(n²). We can probably do better with a hash map.” Naming the naive solution shows you understand the problem and gives you a fallback if the optimal solution doesn’t come.
Step 3: Optimize with patterns
Most interview problems are variations on a small set of patterns. Recognizing the pattern is usually the hardest part.
| Pattern | Signals in the problem | Classic examples |
|---|---|---|
| Hash map / set | “find pairs”, “count”, “seen before”, duplicates | Two Sum, group anagrams |
| Two pointers | Sorted array, pairs, palindromes, in-place changes | Container with most water, 3Sum |
| Sliding window | Contiguous subarray or substring with a condition | Longest substring without repeats |
| Binary search | Sorted input, “minimum X such that”, monotonic condition | Search in rotated array, Koko eating bananas |
| Stack | Matching brackets, “next greater element”, undo | Valid parentheses, daily temperatures |
| Linked list | Cycles, middle, reverse, merge | Reverse list, detect cycle |
| Trees (DFS/BFS) | Hierarchies, paths, levels | Max depth, level order traversal, LCA |
| Graphs | Networks, grids, dependencies | Number of islands, course schedule |
| Heap / priority queue | “Top k”, “k-th largest”, merging sorted lists | Top K frequent, merge k sorted lists |
| Intervals | Overlapping ranges, scheduling | Merge intervals, meeting rooms |
| Backtracking | “All combinations / permutations / subsets” | Subsets, N-Queens |
| Dynamic programming | Optimal value over choices, overlapping subproblems | Climbing stairs, coin change, LCS |
Use input size to guess the target complexity
If n is up to about 10⁵ or 10⁶, an O(n log n) or O(n) solution is usually expected. If n is around 20, exponential approaches like backtracking may be fine. Asking about input size early tells you which patterns are realistic.
Step 4: Code in small steps, out loud
Outline the steps in comments or out loud first, then write the code piece by piece: “Now I’m building the frequency map… now I scan for the first character with count one.”
- Use clear variable names (
left,right,seen), nota,b,x. - Write small helper functions for repeated logic.
- If you’re unsure about a library function, say so and write a simple version.
Phrases that help
- “Let me make sure I understand the constraints…”
- “I’ll start with a straightforward version and optimize after.”
- “I’m not sure about this edge case; let me test it.”
- “If memory were tight, I’d trade time for space by…”
Step 5: Test like an engineer
Walk through your code with the example you wrote, tracking variables out loud. Then check edge cases:
Always check
- Empty input and a single element
- Duplicates and all-equal values
- Negative numbers and zero
- Very large values (overflow in some languages)
- Already sorted and reverse-sorted input
Common bugs
- Off-by-one errors in loops and slices
- Forgetting to update a pointer, so the loop never ends
- Mutating input that the caller still needs
- Returning inside a loop too early
- Not handling a missing key in a map
Finding and fixing your own bug is a positive signal, not a failure.
Step 6: State the complexity
Give time and space complexity and explain where they come from: “We visit each element once and the map holds at most n entries, so O(n) time and O(n) space.” Then mention a trade-off: what you would change for much larger input or tight memory.
An 8-week preparation plan
About 1–2 hours a day. Compress for smaller companies, extend if you are rusty.
- Weeks 1–2: foundationsArrays, strings, hash maps, two pointers, sliding window. Easy and medium problems.
- Weeks 3–4: core structuresStacks, linked lists, binary search, trees with DFS and BFS.
- Week 5: graphs and heapsGrids, BFS and DFS on graphs, topological sort, top-k problems.
- Week 6: harder patternsIntervals, backtracking, an introduction to dynamic programming.
- Week 7: mixed practiceRandom medium problems under a 25-minute timer, out loud.
- Week 8: mock interviewsFull 45-minute sessions with a friend or recording; review weak patterns.
A suggested distribution of your practice problems, weighted toward the most common patterns.
Common mistakes
Strong
- Asks about constraints before coding
- Explains the approach and gets agreement first
- Narrates while coding
- Tests with examples without being asked
- Stays calm and uses hints well
Weak
- Starts typing immediately
- Long silences
- Ignores the interviewer’s hints
- Declares “done” without testing
- Gives up when the optimal solution doesn’t come
Online assessments vs live interviews
Many companies start with an automated online assessment on platforms like HackerRank or CodeSignal. These are timed and scored on test cases, so correctness and speed matter more than communication. Read the rules on the first screen, note which tools are allowed, and practice under the same time limits. The live rounds that follow are where communication becomes decisive.
Beyond algorithms
For mid-level and senior roles, expect a system design interview as well, and behavioral rounds that use the STAR method. Our overview of the tech interview process explains how the rounds fit together, and the interview questions by role section covers language-specific questions such as Python and JavaScript.
Sottena has an “out loud” answer profile that turns a solution into a talk-through outline: restating the problem, the approach, code in chunks with commentary and a dry run. It’s a practical way to rehearse exactly the communication skills described above. Use it in line with the rules of each interview.
Frequently asked questions
How many LeetCode problems should I solve before a coding interview? +
What programming language should I use in a coding interview? +
What if I can't solve the problem? +
Is it okay to ask the interviewer for a hint? +
Should I write tests in a coding interview? +
Get a talk-through outline for coding questions in real time
Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.