Skip to content

Expert: advanced patterns and interviews · Interview strategy and mock problems · topic 58 of 61 · 35 min

Running the coding interview

Explanation

A coding interview checks how you think, not only whether your code runs. Follow a steady plan: restate the problem, clarify inputs and edge cases, work an example, state the brute force and its cost, improve it, agree on the approach, code cleanly, test, and give the complexity. Think aloud the whole time, and when you are stuck, shrink the problem or ask for a hint instead of going silent.

What the interviewer is scoring

Most companies score a coding round on a few things: problem solving (did you find a good approach and reason about it), coding (is the code correct, clean and readable), testing (did you find your own bugs), and communication (could the interviewer follow your thinking). A perfect solution typed in silence can score lower than a good one explained clearly, because the interviewer must write down evidence of how you think.

A step plan for 45 minutes

  1. Listen and restate: say the problem back in your own words. "So I get a list of meeting times and must merge the ones that overlap?"
  2. Clarify: ask about input size, empty input, duplicates, negatives, sorted or not, what to return when there is no answer, and whether you may change the input.
  3. Work an example by hand, including one tricky case. Write it in the editor as a comment.
  4. State the brute force and its cost: "Comparing every pair is O(n²)." This shows you can always produce something correct.
  5. Optimise: look for repeated work, then match a pattern (sorting, hash map, two pointers, heap, DP). Say the new cost.
  6. Agree: "I will sort by start time and merge in one pass, O(n log n). Shall I code that?" Wait for a yes.
  7. Code cleanly: clear names (start, end, merged), small helper functions, no clever one-liners you cannot explain.
  8. Test: walk through your example line by line, then run the edge cases from step 2.
  9. Analyse: state time and space, and what dominates (here, the sort).
  10. Discuss trade-offs: what if the input is huge, streaming, or already sorted? What would you change?

Thinking aloud

Thinking aloud means narrating your reasoning as you go: what you are trying, why, and what you just noticed. It feels strange at first, so practise it alone with a timer. Useful phrases: "My first idea is…", "This fails when…", "The repeated work here is…", "Let me check this with the example…". Silence for more than a minute leaves the interviewer guessing.

When you are stuck

  • Try a smaller example (two or three items) and solve it by hand; notice what you did.
  • Solve a simpler version: sorted input, no duplicates, only positive numbers. Then remove the simplification.
  • Go through the pattern cheat-sheet: could a hash map, a sort, two pointers, a heap or a DP state help?
  • Ask for a hint politely: "I am thinking about sorting first; am I on a useful track?" Taking a hint costs much less than staying stuck.
  • If time is short, code the brute force cleanly and explain how you would improve it.

Online assessments versus live rounds

An online assessment (OA) is a timed test on a platform with hidden test cases and nobody watching. Only correctness and speed count: read the constraints, handle edge cases, and submit partial solutions if the platform gives partial marks. A live round is with an interviewer on a call or in person, often in a shared editor that may not run code. There, communication and testing by hand matter as much as the final code.

Choosing a language

Use the language you write most fluently. Python is short and has collections, heapq and bisect built in, which saves time. Java and C++ are common too, especially in competitive programming and some companies' preferences. Whatever you choose, know its standard tools for lists, maps, sets, heaps and sorting without searching, and know its pitfalls (integer overflow in Java and C++, mutable default arguments in Python).

Common mistakes

  • Jumping into code after hearing the problem. Fix: spend the first 5 to 10 minutes on clarifying, examples and the approach.
  • Not stating the brute force. Fix: always say it with its cost, even if you know the optimal idea.
  • Going silent when stuck. Fix: say what you are trying; ask for a hint after a few minutes.
  • Declaring "done" without testing. Fix: trace one example and the edge cases before you say you are finished.
  • Arguing with a hint. Fix: thank the interviewer and try it; they are helping you.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Running the coding interview · 1/9

Running the coding interview

This lesson gives you a step plan for a live coding interview, so you stay calm and show your thinking.

Prefer a video by a teacher? Find free videos on “how to approach a coding interview think out loud clarify questions mock interview” on YouTube ↗

In real life: A typical 45-minute round

In many product-company interviews in India and elsewhere, a coding round lasts 45 to 60 minutes: a few minutes of introductions, one or two problems, and a few minutes for your questions at the end. A common split for one problem is about 5–10 minutes to clarify and plan, 15–20 minutes to code, and 5–10 minutes to test and discuss. Formats vary by company and team, so ask the recruiter what to expect.

python
plan = [("clarify and examples", 7), ("brute force and optimise", 8),
        ("code", 18), ("test and complexity", 8), ("your questions", 4)]
used = 0
for step, minutes in plan:
    used += minutes
    print(f"{step:<26} {minutes:>2} min  (total {used})")
Prints the five steps with a running total that ends at 45 minutes.

Practice (0/2 done)

Task 1 · Practice

Mock interview script. Take the problem "Merge all overlapping intervals; intervals that touch, like [1, 4] and [4, 5], count as overlapping." Write what you would SAY at each step of the plan, as if the interviewer were listening. Then do it out loud with a 30-minute timer (record yourself or ask a friend to play the interviewer).

Task 2 · Code · Python

Write merge_intervals(intervals). intervals is a list of [start, end] lists with start ≤ end, in any order. Merge every group of overlapping intervals; intervals that touch ([1, 4] and [4, 5]) also merge. Return a NEW list of [start, end] lists sorted by start, and do not change the input. Example: merge_intervals([[1, 3], [2, 6], [8, 10], [15, 18]]) returns [[1, 6], [8, 10], [15, 18]].

Quick quiz

Question 1

1.What should you do first after the interviewer reads out the problem?

Question 2

2.Why say the brute force out loud even when you know a better idea?

Question 3

3.You have been stuck for three minutes. What is the best move?

Question 4

4.What matters MORE in a live round than in an online assessment?

Question 5

5.Which language should you use in a coding interview?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What should you do first after the interviewer reads out the problem?

Answer: Restate it and ask clarifying questions

Restating and clarifying catches misunderstandings before they cost you 20 minutes.

Why say the brute force out loud even when you know a better idea?

Answer: It shows a correct baseline and its cost, and sets up the improvement

A correct baseline proves you can solve it; the improvement then shows insight.

You have been stuck for three minutes. What is the best move?

Answer: Try a smaller example aloud, and ask whether your direction is useful

Shrinking the problem and asking for a nudge keeps you moving and shows how you work.

What matters MORE in a live round than in an online assessment?

Answer: Explaining your thinking and testing by hand

An online assessment only sees the code; a live interviewer scores how you reason and verify.

Which language should you use in a coding interview?

Answer: The one you write most fluently and know the standard library of

Fluency saves time and avoids silly errors; most companies accept common languages such as Python, Java, C++ and JavaScript.

What do interviewers value most during live coding?Related

Answer: Clear thinking aloud and testing your own code

Communication and correctness matter more than clever tricks.

From Classic coding questions

In a machine coding round, what should you do first?Related

Answer: Get a simple working version of the main feature, then improve it

A working end-to-end version is the base. Edge cases and polish come after, if time allows.

From Full-stack interviews in India

What should you do first when given a coding question?Related

Answer: Restate the problem and ask about edge cases

Understanding the problem and its edge cases first avoids solving the wrong problem.

From Python interview preparation

Which plan is most likely to work in the month before interviews?Related

Answer: Daily practice of questions aloud, SQL and DSA problems, project polish, and mock interviews

Interviews test speaking, coding and project knowledge together. Steady daily practice and mocks cover all three.

From Backend interview preparation

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 3 more topics in “Interview strategy and mock problems” before its exam: Testing, edge cases and debugging under pressure, Mock problems: design-style data structures, Your study plan and the job hunt.
  2. Module 12 exam: Interview strategy and mock problems · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. 61 topics left in the course before the final exam.

← Previous: Recognising the pattern