How to prepare for a debugging interview
In a debugging interview you get code you didn’t write, with a bug in it. You find the bug and fix it while the interviewer watches how you work. Some companies call it a debugging round or a bug squash. Expect 45 minutes to an hour, most often on your own machine.
By NextBeingUpdated 6-minute read, with 9 bugs to find
To prepare for a debugging interview, practice out loud on programs that fail. Read the output first and decide where it points: the line with the bug, the line where the program stopped, or only the test that failed. Then make one guess, test it, and make the smallest fix. Before the round, get a project with tests running on your own machine.
9 debugging interview practice questions
Each one is a short program that fails, in Python, JavaScript, Rust, C++ or SQL. Press Run and read the output. Say out loud where it points and what you think is wrong, then click the line with the bug. You get two tries.
Nothing run yet. Press Run.
Traceback (most recent call last):
File "word_counts.py", line 12, in <module>
assert word_counts("the cat the") == {"the": 2, "cat": 1}
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "word_counts.py", line 8, in word_counts
counts[w] += 1
~~~~~~^^^
KeyError: 'the'
After the fix: ok
Say it like this“It's a KeyError on line 8, on the very first word. There's no count for that word yet, so I'd start each word at zero.”
Nothing run yet. Press Run.
initials.js:8
.map((part) => part[0].toUpperCase() + ".')
^^^^
SyntaxError: Invalid or unexpected token
After the fix: ok
Say it like this“It's a syntax error, so nothing ran. Line 8: the string opens with a double quote and closes with a single one.”
Nothing run yet. Press Run.
error[E0308]: mismatched types --> sort_desc.rs:6:22 | 6 | v.sort_by(|a, b| b - a); | ^^^^^ expected `Ordering`, found `i32` error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`.
After the fix: ok
Say it like this“It doesn't compile. Line 6 has to return an Ordering and it returns a subtraction. I'd compare with cmp.”
Nothing run yet. Press Run.
longest.js:6
return words.reduce((best, w) => (w.length > best.length ? w : best));
^
TypeError: Reduce of empty array with no initial value
at Array.reduce (<anonymous>)
at longest (longest.js:6:16)
at Object.<anonymous> (longest.js:11:20)
After the fix: ok
Say it like this“The first test passes, so it works for a normal list. It's the empty list: reduce has nothing to start from. I'd give it an empty string to start with.”
Nothing run yet. Press Run.
Traceback (most recent call last):
File "row_totals.py", line 15, in <module>
assert row_totals([[1, 2], [3, 4]]) == ([3, 7], 10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "row_totals.py", line 9, in row_totals
t = sum(row)
^^^^^^^^
TypeError: 'int' object is not callable
After the fix: ok
Say it like this“It stops on line 9, but that line looks right. 'int is not callable' means sum is a number there, and line 6 is what makes it one. I'd rename that variable to total.”
Nothing run yet. Press Run.
node:assert:150
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected
[
3,
5,
7,
+ NaN
]
at Object.<anonymous> (pair_sums.js:14:8)
After the fix: ok
Say it like this“The test on line 14 got one value too many, a NaN at the end. So the loop runs one step past the last pair. It's an off-by-one: I'd stop the loop one step earlier.”
Nothing run yet. Press Run.
Traceback (most recent call last):
File "find_index.py", line 19, in <module>
assert find_index([1, 3, 5, 7], 7) == 3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
After the fix: ok
Say it like this“Searching for 3 works and searching for the last element doesn't, so it's a boundary. When lo and hi meet there's still one element to look at, and the loop stops there.”
Nothing run yet. Press Run.
Assertion failed: (sumAll({2000000000, 2000000000}) == 4000000000LL), function main, file sum_all.cpp, line 15.
After the fix: ok
Say it like this“Small sums pass and the four-billion one fails, so something overflows. The return type is long long, but the adding happens in an int. I'd make total a long long.”
Nothing run yet. Press Run.
[('Ana', 250), ('Ben', 70)]
Traceback (most recent call last):
File "totals.py", line 26, in <module>
assert rows == [("Ana", 150), ("Ben", 70)], rows
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: [('Ana', 250), ('Ben', 70)]
After the fix: [('Ana', 150), ('Ben', 70)]
ok
Say it like this“Ana shows 250 and it should be 150. That's exactly one extra 100, the order paid in two parts. The payments join repeats it, and the total doesn't need payments at all.”
| What the output pointed to | Found |
|---|---|
| The output points to the line with the bug. | |
| The output points to where it stopped. The bug is earlier. | |
| The output only shows which test failed. |
How do you read a stack trace or a failed run?
Find the line that names the error. A Python traceback puts it last. Node and compilers put it near the top, next to the file and the line. Then look at where it points, which is one of three places.
row_totals.py stops on line 9 because of what line 6 did.pair_sums.js.What happens in a debugging interview?
You get a codebase with a bug in it and 45 minutes to an hour. Expect finding the bug to take longer than fixing it. In a 2017 experiment, 12 developers, 11 of them professionals, took 32 minutes on average to find a real bug and 16 to fix it (source 3).
Expect a failing test to start from, or a report of what goes wrong. NextBeing read 20 public first-hand accounts of debugging interviews in November 2026: 12 by people who give the round and 8 by candidates. The bug shows up as a failing test in 4 of them, and in a fifth the candidate works until the tests pass. In 3 it comes as a report of what goes wrong. One interviewer hands over code whose tests all pass, and two more describe a round where you read the code and say what is wrong, with no test mentioned. Six of the 8 candidates worked on their own machine. Two accounts give the length as about an hour and a third works out at 45 minutes, the length our coding interview time management plan uses. How we counted
Do you have to find the bug to pass?
Two of the 12 interviewers say outright that you don’t. A third scores whether you follow a guess through to a conclusion, and says a wrong guess is fine if you test it and drop it. One disagrees: if solving the bug doesn’t count, the scoring turns arbitrary. Plan to find it. If time runs out, say what you’ve confirmed, your current guess, and the next thing you’d check. Needing a hint isn’t a fail: one candidate in the accounts got one and passed.
What do you say while you debug?
Five things, in this order. Each of the 9 programs above ends with an example of the first two, and for most the fix too.
- Read it“The error says… on line…”
- Guess“My guess is… because…”
- Check it“The quickest way to check that is…”
- Fix it“It’s a small fix. I’ll change…”
- Add a test“The test that would have caught this is…”
On the first program above, the third sounds like this: “The quickest way to check that is to print the dictionary just before line 8.”
How do you find your way in a large codebase?
Reproduce the bug first: run the failing test and read what it prints. A long stack trace often has more library frames than yours. Find the frame in a file you were given that is closest to the error: the last one in a Python traceback, the first one in Node. Read the function it names, then the functions that one calls, and leave the rest of the repository alone until the trail leads there.
When the output doesn’t name the line, print the value before and after the call you suspect, and change one thing at a time. When all you have is an error message, search the code for its words. That takes you to the line that printed it.
Can you use print statements, a debugger or AI tools?
Expect prints to be allowed. None of the 20 accounts describes a ban on them. In a 2018 study, 72% of the 176 developers surveyed said they debug with print statements, and 81% said they use their editor’s debugger. The study also tracked 458 developers’ editors for a median of six days, and 29% of them started the debugger (source 4). None of the accounts states a rule on AI tools, so ask your recruiter before the day.
Learn three debugger actions in your own editor before the round: set a breakpoint, step one line, and print a variable. One candidate describes a debugger setup that felt clunky in the round, and ending up with prints.
How do you practice for a debugging interview?
- Small programs first. Do the 9 above until you can say where the output points before you look at the code.
- Your own code, broken by someone else. Take a solution you wrote last month and ask a friend to change one line. Good changes to ask for: an off-by-one, a missing empty-input case, a value counted twice.
- A real project. Clone a small open-source project in your language and run its tests. Pick a bug fix from its history, check out the commit before it, and find the bug from the report.
- Your setup. Do step 3 on the machine and editor you’ll use in the round. Two candidates describe the time going to setup instead: an old laptop with an unfamiliar editor, and a project that couldn’t be run reliably.
All 9 programs and their fixes as a table
| Program | Language | The error it prints | What the output points to | The line with the bug | The fix |
|---|---|---|---|---|---|
| 1. word_counts.py | Python | KeyError: 'the' | The line with the bug | Line 8: counts[w] += 1 | line 8: counts[w] = counts.get(w, 0) + 1 |
| 2. initials.js | JavaScript | SyntaxError: Invalid or unexpected token | The line with the bug | Line 8: .map((part) => part[0].toUpperCase() + ".') | line 8: .map((part) => part[0].toUpperCase() + ".") |
| 3. sort_desc.rs | Rust | error[E0308]: mismatched types | The line with the bug | Line 6: v.sort_by(|a, b| b - a); | line 6: v.sort_by(|a, b| b.cmp(a)); |
| 4. longest.js | JavaScript | TypeError: Reduce of empty array with no initial value | The line with the bug | Line 6: return words.reduce((best, w) => (w.length > best.length ? w : best)); | line 6: return words.reduce((best, w) => (w.length > best.length ? w : best), ""); |
| 5. row_totals.py | Python | TypeError: 'int' object is not callable | Where it stopped; the bug is earlier | Line 6: sum = 0 | line 6: total = 0; line 11: total += t; line 12: return totals, total |
| 6. pair_sums.js | JavaScript | AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: | Only the test that failed | Line 7: for (let i = 0; i < xs.length; i++) { | line 7: for (let i = 0; i + 1 < xs.length; i++) { |
| 7. find_index.py | Python | AssertionError | Only the test that failed | Line 7: while lo < hi: | line 7: while lo <= hi: |
| 8. sum_all.cpp | C++ | Assertion failed: (sumAll({2000000000, 2000000000}) == 4000000000LL), function main, file sum_all.cpp, line 15. | Only the test that failed | Line 8: int total = 0; | line 8: long long total = 0; |
| 9. totals.py | SQL in Python | AssertionError: [('Ana', 250), ('Ben', 70)] | Only the test that failed | Line 19: JOIN payments p ON p.order_id = o.id | line 19 removed |
In NextBeing’s coding exercises, a failed Run comes back as one message: what broke, the line, and the change that fixes it. Use it in a live interview only where AI help is allowed.
NextBeing for coding roundsHow the exercise was made
The 9 programs come from the set NextBeing uses to test how it reads a failed run. We ran each one on November 28, 2026 with Python 3.12.16, Node.js v22.23.5, rustc 1.100.0 and clang 21.0.0. Then we ran it again with its fix, and kept the fix only when it printed ok. The output is shown as printed, with the folder path removed. For JavaScript, everything from Node’s own stack frames on is cut. The programs are 12 to 27 lines long. The code in a real round is larger, and its stack traces can be longer, with library frames among yours.
The 20 accounts
In November 2026 we searched for debugging interview, debugging round and bug squash, and kept 20 public first-hand accounts from 2019 to 2026: 12 by people who give the round, 8 by candidates. Eleven come from one forum discussion of August 2024, the post and ten commenters under it. The rest are blog posts and forum posts. One was read as a preview only, one was edited by the site that published it, and one describes a troubleshooting interview with no code handed over. Three of the 12 don’t state their role, and we took it from what they write. We count an account only when it states the point outright. Twenty accounts is a small sample, so ask your recruiter how your round is run.
Sources
- NextBeing, the 9 programs on this page and their runs, November 28, 2026.
- NextBeing, a review of 20 public first-hand accounts of debugging interviews, November 2026.
- Böhme and others, “Where is the bug and how is it fixed? An experiment with practitioners”, ESEC/FSE 2017: 11 professional engineers and one researcher, 27 real bugs in two C programs, times as the participants reported them.
- Beller and others, “On the dichotomy of debugging behavior among programmers”, ICSE 2018.
Next: coding interview time management, a 45-minute plan, and a whole coding round played out.