Skip to main content
VirtualInterview.ai
Technical Interviews

What to do when you get stuck in a coding interview

Getting stuck in a coding interview is normal, and how you handle it is part of what's being assessed. Say that you're stuck and what you've tried, go back to a small example and work it by hand, try a simpler version of the problem or a brute-force solution,…

By VirtualInterview.ai5 min read
  • technical interviews
  • interview preparation

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:

  1. Re-read the code out loud, line by line. Many bugs show up when you say what each line does.
  2. Trace a small input through it, writing down the variable values.
  3. Check the usual suspects: off-by-one errors in loops, the empty input, the last element, variables that aren't reset.
  4. 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.

Enjoyed this article?

Share it with your network or save it for later.

From the editorial desk

VirtualInterview.ai team

Career coaches, HR professionals, and AI specialists.

About us

Get interview tips by email

Get expert advice on interviews, career growth, and AI preparation strategies.

No spam. Unsubscribe anytime.

View all

Technical Interviews

How to Explain a Project You Built in a Technical Interview

Explain your project in about two minutes, starting with the problem it solved and who it was for, not the tools you used. Build the walkthrough around the constraint you faced, your main technical decision and its tradeoff, a setback that forced a change, and the result. Keep a 30-second summary for casual questions and a longer version for "walk me through it." When you can't answer a question, say so plainly and explain how you would find out, rather than bluffing or going silent. Rehearse ou

· 5 min read

Technical Interviews

How to explain your approach out loud in a coding interview

In a coding interview, the interviewer scores your reasoning as much as your code, and they can only score what they hear. Restate the problem, ask about inputs and edge cases, describe a simple approach before coding, say its cost, then narrate decisions while you write. Test out loud with a small example at the end. Practise talking while coding, because it is a separate skill from solving problems.

· 5 min read

Technical Interviews

System design interview: how to structure the conversation

A system design interview usually goes wrong because the conversation gets hard to follow, not because you lack knowledge. Agree on requirements first, say your plan out loud, then walk one request flow, one data flow and one failure flow before naming tools. Pick one option at each decision and say what it costs. When you hit a gap, reason from the constraints instead of guessing. Rehearse one outline aloud with a timer until it survives nerves and interruptions.

· 6 min read

Browse by topic