At some point in most coding interviews, you'll get stuck. The approach you had in mind won't work, or you can't see how to start, or a bug refuses to show itself. Many candidates treat this as the moment the interview is lost and either freeze or start changing code at random.
Interviewers expect people to get stuck. Many choose problems so that most candidates do. What they're watching is how you get unstuck.
Say that you're stuck
Silence is the worst option. The interviewer can't tell whether you're thinking productively or panicking, and they can't help. Say where you are:
"I'm stuck on how to handle the overlapping intervals. My plan was to sort by start time, but I can't see how to know when a room frees up without checking every previous meeting."
That one sentence tells them what you understand, where the gap is, and gives them something to respond to.
Go back to a small example
When an abstract approach isn't coming, work through a small concrete example by hand, out loud:
"Let me take three meetings: 9 to 10, 9:30 to 11, and 10 to 11:30. At 9:30, the first is still going, so I need a second room. At 10, the first one ends, so the third can reuse its room. So what I need to know at each start time is the earliest end time among the rooms in use..."
Doing it by hand very often shows you the structure you need. In this case, it points straight to keeping the end times in order.
Try a simpler version
If the full problem is too hard, solve a smaller version first:
- a smaller input ("what if there were only two meetings?")
- fewer constraints ("ignore the time limit for now")
- a special case ("what if the list were already sorted?")
Then extend it. Solving a simpler version still shows reasoning, and it often reveals the general solution.
Offer the brute-force solution
If you can't find the efficient approach, say so and offer the simple one:
"I can see a brute-force solution that checks every pair, which is quadratic. Should I write that first and then try to improve it?"
Many interviewers will say yes. A working slow solution plus a clear explanation of how you'd improve it usually scores better than an unfinished clever one.
Use hints well
When the interviewer gives a hint, it's not a failure. It's part of the interview, and how you use it is assessed.
- Listen fully before responding.
- Repeat it back to check you understood: "So you're suggesting I think about what happens at each end time?"
- Say how it changes your approach before you start coding again.
- Don't argue with it, even if you were heading somewhere else. You can mention your original idea briefly.
If you get a hint and still can't see it, it's fine to say: "I can see that's important, but I'm not yet seeing how to use it. Let me try the small example again with that in mind."
When it's a bug, not the approach
If your approach is right but the code doesn't work:
- Re-read the code out loud, line by line. Many bugs show up when you say what each line does.
- Trace a small input through it, writing down the variable values.
- Check the usual suspects: off-by-one errors in loops, the empty input, the last element, variables that aren't reset.
- Add a print statement if you can run the code.
Narrate as you go. "The loop should run three times, but it's stopping at two, so the condition must be wrong."
Manage the clock
If you've been stuck on one part for several minutes, tell the interviewer and suggest a way forward:
"I've spent a while on this part. Could I write the rest assuming I have a function that gives me the next free room, and come back to it?"
Finishing the overall structure with one piece outlined is often better than an unfinished solution.
What not to do
- Sit in silence for minutes.
- Delete everything and start over without explaining why.
- Change code at random to see what happens.
- Claim the solution works when you haven't tested it, or when you know it doesn't.
- Apologise repeatedly. One "I'm stuck here" is enough; then work the problem.
Practise getting stuck
The usual practice of solving problems alone doesn't train you for this, because when you're stuck alone you can look at the answer. Make yourself work through it out loud for ten minutes before you check, using the steps above. Mock interviews with a friend help too.
Explaining your reasoning while stuck uses the same habits as explaining it when things are going well, which is covered in how to explain your approach out loud. An AI mock interview set to a technical round lets you practise talking through a problem, including the parts you're unsure of, and get scored on clarity.
The general version of this skill, for any interview, is in how to answer a question you don't know.
Your next step
Next time you get stuck on a practice problem, set a ten-minute timer before looking at any solution, and work through the steps out loud: say where you're stuck, try a small example, try a simpler version.