JuniorInterviews

In a live coding interview, what do you do before you write the first line of code?

Interviewers ask this to see whether you have a process or just type out of reflex. A good answer shows that you spend the first few minutes understanding the task, because that is the cheapest part of the whole session.

You can answer in three steps:

  1. Restate the task in your own words and ask about the unclear parts. For example, with a task like "count the note that appears most often": "Do uppercase and lowercase count as the same? If two notes appear the same number of times, how do I order them? Can the array be empty or contain blank entries?" Your questions show that you can spot where the task is unclear, and the answers pin down the rules of the problem.
  2. Walk through one example by hand, talking as you go. This often reveals a rule you haven't handled, before you have written a single line of code.
  3. Say the approach before you write it. One or two sentences, for example "I'll normalize each note, count with a Map and then sort in descending order." If that direction is off, the interviewer has a chance to steer you before you lose ten minutes.

It is worth adding the reason: if you misunderstand the task, all the code after it is wasted effort, and the interviewer is judging how you think, not only the result. If you get stuck, say where you are stuck and what you are trying, instead of going silent.

Bonus points: tell about a bug that the walk-through by hand helped you catch early, for example code that compared strings as written, so "Cà phê " and "cà phê" were counted as two different notes.