Video in progress

During live coding, what should you say out loud instead of typing in silence?

I restate the problem in my own words, ask about edge cases, explain the approach before writing it, and while writing I say what I'm doing at each step.

📖 Answer

In live coding the interviewer evaluates your thinking. If you type in silence, they only see the result, and if the result is wrong, you have no points left.

The sequence goes roughly like this:

  1. Restate the problem: "So I need to return the first non-repeating element in the list, right?"
  2. Questions: can the list be empty? What about null elements? How big is it?
  3. Approach: "First the simple version, two nested loops, O(n²). Then I'll make it O(n) with a LinkedHashMap."
  4. Write and comment: "Here I'm counting the frequencies…"
  5. Check: walk a small example through by hand.
// code written "out loud" looks like this
Map<String, Integer> counts = new LinkedHashMap<>(); // to keep the order
for (String s : items) counts.merge(s, 1, Integer::sum);

Even if you freeze, keep talking: "I mixed up the index just now, one second, I'll check with an example." That's much better than silence.