Code Review & Bug Squashing Arena

Debugging Challenge

Real-world buggy snippets: off-by-one errors, state mutations, race conditions, and memory leaks. Find and fix them.

Squashed
0 / 3
XP per Fix
+40 XP
javascript Bug
Medium

Off-By-One Infinite Loop in Binary Search

A teammate submitted this binary search implementation, but it hangs in an infinite loop on certain target searches and misses valid elements. Diagnose and fix the boundary logic.

Verification Test Cases (3)

Test #1:
Input: [[1,3,5,7,9],7]
Expected: 3
Test #2:
Input: [[1,3,5,7,9],2]
Expected: -1
Test #3:
Input: [[2,5],5]
Expected: 1
solution.jsFix The Bug