Spot the bug: coding interview edition
Each puzzle is a short Python solution to a classic interview problem with one real bug: an off-by-one, a wrong base case, a pointer that moves the wrong way. Tap the line you think is wrong (two tries), read why, then fix it and run the tests in your browser. The bugs are the ones that pass the obvious example and fail the edge case, which is exactly what interviewers look for.
You found 0 of 12 bugs
1. Binary search that misses the last element
Binary Search
2. Two Sum that uses the same number twice
Two Sum
3. Valid Parentheses that accepts "(("
Valid Parentheses
4. Stock profit that's always too high
Best Time to Buy and Sell Stock
5. Merge Intervals that shrinks an interval
Merge Intervals
6. Sliding window whose left edge jumps backwards
Longest Substring Without Repeating Characters
7. Number of Islands that crashes on the edge
Number of Islands
8. Kth Largest that reads the wrong end of the heap
Kth Largest Element in an Array
9. Daily Temperatures that counts equal days as warmer
Daily Temperatures
10. House Robber with a broken base case
House Robber
11. Container With Most Water that moves the wrong pointer
Container With Most Water
12. Contains Duplicate that remembers the last call
Contains Duplicate