Lesson 27 of 30
A quiet correct answer tells an interviewer less than you'd think. A narrated attempt tells them almost everything they actually need to know.
10 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
This topic is about judgment and practical tradeoffs more than a single right answer — a mock interview is the better way to test yourself on it.
Be interviewed on this →Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Imagine watching two people assemble furniture. One works in total silence and hands you a finished chair. The other talks the whole way through — "this screw looks like it goes here, let me check the diagram, actually I had that backwards" — and hands you a chair that's slightly wobbly.
Which one would you trust to assemble a harder one next, without instructions? Probably the person who talked. You watched them catch their own mistake. You have no idea how the silent person got their result — skill, luck, or memorizing this exact chair before.
An interview isn't a test of whether you can produce a correct answer. It's a test of whether you can think, in a way another engineer can watch and trust. A silent correct answer gives almost no signal — just a coin flip's worth of evidence you're good at this one problem. A narrated attempt, even incomplete, shows exactly how you reason and recover from a wrong turn. That's what they're actually hiring for.
// SILENT approach: interviewer sees this appear on the screen with
// no explanation, and has to guess how you got here.
function hasPair(nums, target) {
const seen = new Set();
for (const n of nums) {
if (seen.has(target - n)) return true;
seen.add(n);
}
return false;
}
// NARRATED approach — same code, but said out loud first:
// "I'll brute-force this first: check every pair, that's O(n^2).
// But I notice I keep re-checking numbers I've already seen — what
// if I remember them instead? A Set gives me instant lookup, so as
// I scan once, I can ask 'have I seen the number that would pair
// with this one?' That gets me to one pass, O(n) time."
function hasPair(nums, target) {
const seen = new Set();
for (const n of nums) {
if (seen.has(target - n)) return true; // "the complement I need"
seen.add(n); // "remember this one too"
}
return false;
}
The code is identical. The second version gives the interviewer a window into why it works, which is the entire point of the exercise.
The six-step framework from earlier in this track gives you something concrete to narrate — "restating the problem," "trying a small example," "starting with brute force" are all natural things to say out loud, in order, as you work through them.