Find the bug

Code that looks right and is not. Run it, find the bug, fix it with the smallest change.

  1. Fix the Binary Search A binary search that misses some targets: find the off-by-one and fix it. Easy Most asked All 5 languages
  2. Fix the Two Sum Hash Map A one-pass Two Sum that sometimes pairs a number with itself. Easy Most asked All 5 languages
  3. Fix the Longest Substring Without Repeats A sliding window whose left edge sometimes moves backwards. Medium Most asked All 5 languages
  4. Fix Merge Intervals An interval merge that shrinks intervals when one contains another. Medium Most asked All 5 languages
  5. Fix the Mutable Default Argument A Python helper whose results leak from one call into the next. Easy Most asked Python
  6. Fix the Substring Check A contains-check that says no when the match is at the very start of the string. Easy Most asked All 5 languages
  7. Fix the Median (JavaScript Sort) A median function that is right for single digits and wrong for 10. Easy Most asked Node.js, TypeScript
  8. Fix the Number Parser (map + parseInt) A one-line parser that turns most of its input into NaN. Easy Node.js, TypeScript
  9. Fix the Async Total (forEach) An async loop that returns before any of its work has finished. Medium Most asked Node.js, TypeScript
  10. Fix the Bill Splitter Splitting money with rounding loses or invents cents. Easy All 5 languages
  11. Fix the Pagination Helper Page 1 shows the second page of results. Easy Most asked All 5 languages
  12. Fix the TTL Cache Expiry A TTL cache that serves entries one tick after they expired. Medium All 5 languages
  13. Fix Removing Items While Iterating Deleting from a list inside the loop that walks it skips elements (or throws, in Java). Easy Most asked Node.js, TypeScript, Python, Java
  14. Fix the Word Counter A word counter that counts the spaces between words, and counts one word in an empty string. Easy All 5 languages
  15. Fix the Bracket Validator A bracket validator that accepts brackets that were opened and never closed. Easy Most asked All 5 languages

← All coding problems