Find-the-bug coding interview questions
Debugging and code-review rounds are now a standard part of technical interviews, and with AI writing more code, reading it critically matters more than ever. Here are 30 short, realistic snippets, each with exactly one real bug, a clear explanation and a production-ready fix.
Interview questions by language
- Python5 questionsDefault arguments are evaluated once, at definition time. Negative slicing with a variable breaks when the variable is 0.
- JavaScript5 questionsArray.prototype.sort() compares strings unless you pass a comparator. 0, "" and NaN are falsy; use == null to test for missing values.
- TypeScript5 questionsThe ! operator silences the compiler; it doesn't make the value exist. Async responses can resolve out of order; only the latest should win.
- Go5 questionsMaps are not safe for concurrent writes; guard them or use one per goroutine. Always close resp.Body, even if you don't read it.
- Java5 questions== compares references; use equals() for Strings and boxed numbers. Optional.get() throws on empty; prefer map/orElse.
- SQL5 questionsNothing equals NULL; use IS NULL / IS NOT NULL. BETWEEN on timestamps silently drops the last day; use half-open ranges.
Interview questions by bug type
How to answer a spot-the-bug interview question
- Say what the code is supposed to do, in one sentence.
- Walk through it with a normal input, then with edge inputs: empty, zero, null, very large, concurrent calls.
- Point to the exact line and explain what breaks, for whom, and when.
- Propose the smallest correct fix, then mention how you'd test it.
- Offer a follow-up: how to prevent the whole class of bug (types, linters, tests, code review checklists).
FAQ
What is a find-the-bug coding interview question?
You get a short, realistic piece of code that contains a bug and you're asked to find it, explain what breaks and propose a fix. It tests code-reading, debugging and code-review skills rather than algorithm memorization.
Which companies ask debugging or code review questions?
Many teams now include a code-review or debugging round, especially for backend, full-stack and senior roles, because reviewing AI-generated and teammates' code is a large part of the job.
How should I answer a spot-the-bug question?
Read the code top to bottom, state what it's supposed to do, test it mentally with normal and edge inputs (empty, zero, null, concurrent calls), point to the exact line, explain the failure and give a minimal fix.
How can I practice debugging every day?
Play Spot the AI Bug: every day there's a new AI-written pull request with one real bug. Find the line in three attempts, name the bug type and compare your streak with friends.
Are these questions free?
Yes. All interview questions on this site and the daily puzzle are free to play.