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.
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:
| Signal | What they want to see | What silence gives them |
|---|---|---|
| Problem solving | You find an approach and improve it | Nothing until the code appears |
| Communication | You explain trade-offs a teammate could follow | Nothing |
| Coding | Clean, correct code at a sensible pace | Only the final file |
| Verification | You test your own code and find your own bugs | Nothing, 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.
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.
Understand. These three stages prove you know what is being asked before you solve anything. Budget about 5 minutes.
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
nget? 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 the narration stages in the order you would use them in an interview.
- Tap the steps below in the right order.
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 each bad habit to the better move.
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.
Press Run (⌘ Enter) to see what happens.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.
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^4sandtcontain only lowercase English letters.
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.
- 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.