Skip to content

Lesson 13 of 27Talk it through

Thinking Out Loud

Narrate each stage of a coding interview so the interviewer can follow, help, and score your thinking.

13 min read0/5 questions

You now have a route from a fresh problem to a traced plan. In an interview you walk that route with someone listening. A correct solution typed in silence often scores lower than a slightly rougher one explained clearly. The interviewer is not grading a file. They are writing notes on how you think, and they can only write down what they hear.

This lesson gives you a script for every stage: what to say, how to say it, and the habits that quietly cost people offers.

Why the interviewer needs your thinking

Most interview loops score a handful of signals. The exact rubric varies by company, but it usually looks like this:

SignalWhat they want to seeWhat silence gives them
Problem solvingYou find an approach and improve itNothing until the code appears
CommunicationYou explain trade-offs a teammate could followNothing
CodingClean, correct code at a sensible paceOnly the final file
VerificationYou test your own code and find your own bugsNothing, unless you test out loud

If you sit quiet for ten minutes and then produce a perfect answer, the interviewer has one data point and three empty boxes. Worse, if you go quiet down the wrong path, they cannot steer you, because they do not know where you are.

Thinking out loud is also how you get help. Interviewers are usually allowed to give hints, but they give them in response to what you say. "I am stuck on how to avoid checking every pair" invites a hint. Staring at the screen does not.

Quick check
You solve the problem silently in 15 minutes and the code passes every test. What is the most likely feedback?
Need a nudge? A hint rules out a wrong answer.

What to say at each stage

The stages below match the Decoder you used earlier in this track. Each one has a job, and each job has a short thing to say.

The narration stages
  1. 1. RestateSay the problem back in one sentence, in your own words.
  2. 2. ClarifyAsk about input size, duplicates, empty input, return format.
  3. 3. ExamplesWalk one small example by hand, including an edge case.
  4. 4. Brute forceName the obvious approach and its cost.
  5. 5. OptimisePoint at the bottleneck and the tool that removes it.
  6. 6. Agree the planSummarise the steps and get a nod before typing.
  7. 7. CodeNarrate intent, not syntax.
  8. 8. TestDry run an example, then edge cases.
  9. 9. ComplexityState time and space, and why.

Understand. These three stages prove you know what is being asked before you solve anything. Budget about 5 minutes.

1/4

Sentence starters

You do not need to be eloquent. You need a few reliable phrases you can reach for under pressure.

Restate and clarify

  • "So I need to return … given … Is that right?"
  • "Can the array be empty? Can values be negative? Can there be duplicates?"
  • "Roughly how big can n get? That tells me what complexity I am aiming for."

Brute force and optimise

  • "The straightforward way is … That is O(n²) because …"
  • "The repeated work is … If I could look that up in O(1), I would be at O(n)."
  • "I am choosing a hash map over sorting because I need the original indices."

Plan and code

  • "Here is the plan: first …, then …, finally … Does that sound reasonable before I code it?"
  • "This loop builds the map. Next I handle the case where …"
  • "I am going to write a helper for this so the main loop stays readable."

Test and wrap up

  • "Let me trace [2, 7, 11] with target 9. At index 0 the map is empty, so …"
  • "Edge cases I want to check: empty input, one element, all duplicates."
  • "This is O(n) time and O(n) space for the map. If memory were tight, I could sort instead and pay O(n log n)."
Put it in order6 steps

Put the narration stages in the order you would use them in an interview.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.

What not to do

Three habits do most of the damage.

Silence. A minute of quiet thinking is fine, as long as you announce it: "Give me a moment to think about how to avoid the nested loop." Then come back with what you found, even if it is "I have not got it yet, here is what I tried."

Rambling. The opposite failure. Narrating every keystroke ("now I type for, now i, now in") buries the signal. So does listing six approaches without choosing one. Say the idea, the reason, and move.

Coding before agreeing a plan. If you start typing the moment you have an idea, the interviewer cannot tell you it is wrong until you have spent ten minutes on it. One sentence of plan and a "does that sound good?" costs fifteen seconds.

A few smaller ones: asking "is this right?" after every line (confidence matters), arguing with a hint, and going quiet when you find a bug. A bug you find and explain yourself is a positive signal.

Match the pairs0/5 matched

Match each bad habit to the better move.

Choose an item, then its match on the other side.

A model transcript

Here is what a good session sounds like on Valid Anagram: given two strings, are they rearrangements of each other? Read it once, then notice how little of it is about syntax.

Transcript: Valid Anagram (about 12 minutes)

Candidate: So I get two strings, s and t, and I return true if t uses exactly the same letters as s, the same number of times each. Is the input only lowercase English letters, or could it be any Unicode?

Interviewer: Lowercase letters for now.

Candidate: Great. And lengths up to about 5 × 10^4? Then anything up to O(n log n) is fine. Quick example: "anagram" and "nagaram" should be true; "rat" and "car" false because t has a c. Edge case: different lengths, which is an instant false.

Candidate: The simplest idea is to sort both strings and compare. That is O(n log n). I can do better by counting: one pass over s adds to a count per letter, one pass over t subtracts, and every count must end at zero. That is O(n) time, and space is O(1) because there are only 26 letters. Does counting sound good?

Interviewer: Go ahead.

Candidate: First the length check. Then a dictionary of counts. I add for s, subtract for t, and if any count goes negative I can stop early, because t has an extra letter.

Candidate: Let me trace "rat", "car". Counts after s: r1, a1, t1. Then c goes to minus 1, so I return false. Good. Empty strings: lengths match, no letters, returns true, which is correct.

Candidate: Final: O(n) time, O(1) extra space for 26 letters. If the follow-up is Unicode, the same code works with a hash map, and the space becomes O(k) for k distinct characters.

Pythonanagram.py
def is_anagram(s: str, t: str) -> bool: if len(s) != len(t): return False counts: dict[str, int] = {} for ch in s: counts[ch] = counts.get(ch, 0) + 1 for ch in t: counts[ch] = counts.get(ch, 0) - 1 if counts[ch] < 0: return False return True print(is_anagram("anagram", "nagaram"))print(is_anagram("rat", "car"))print(is_anagram("", ""))
Output
Press Run (⌘ Enter) to see what happens.
Quick check
In the transcript, what did the candidate do right before writing any code?
Need a nudge? A hint rules out a wrong answer.
Quick check
Halfway through coding you notice your loop skips the last element. What is the best thing to say?
Need a nudge? A hint rules out a wrong answer.

Practice it

Narration is a skill you build with reps, not something you learn by reading. Open the Decoder, pick any problem, and say each stage out loud before you reveal it. When you reach the talk-through stage, compare your version with the model one: did you restate, give the brute force cost, name the insight, and mention an edge case?

Record yourself once. It is uncomfortable, and it is the fastest way to hear your own silences and filler.

ChallengeEasy

Valid Anagram

Two strings are anagrams when one is a rearrangement of the other: same letters, same counts, any order. Given strings s and t, return true if t is an anagram of s.

s = "listen", t = "silent"   →  true
s = "rat",    t = "car"      →  false
s = "aab",    t = "abb"      →  false   (counts differ)

Constraints

  • 0 <= s.length, t.length <= 5 * 10^4
  • s and t contain only lowercase English letters.
def is_anagram(s: str, t: str) -> bool: # Count the letters in each string and compare. pass
ChallengeEasy

Two Sum

Given a list of integers nums and a number target, find the two different positions whose values add up to target. Return their indices as a list in increasing order.

nums = [2, 7, 11, 15], target = 9    →  [0, 1]   (2 + 7)
nums = [3, 2, 4],      target = 6    →  [1, 2]   (2 + 4)
nums = [3, 3],         target = 6    →  [0, 1]

You may not use the same index twice.

Constraints

  • 2 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9
  • Exactly one valid answer exists.
def two_sum(nums: list[int], target: int) -> list[int]: # For each number, what partner would you need? pass
Key terms
think-aloud
Saying your reasoning as you go so the interviewer can follow, score, and help.
restate
Repeating the problem in your own words to confirm you understood it before solving.
agree the plan
Summarising your approach and getting a nod before writing code.
narrate intent
Explaining what a block of code is for, not reading the syntax aloud.
signal
Evidence an interviewer can write down: problem solving, communication, coding, verification.