Algorithms·hard 30 min 120 XP
Binary Search
Return the index of a target in a sorted array, or -1 if not found, using binary search.
Examples
- binarySearch([1,3,5,7,9], 7) → 3
Constraints
- Keep the required function name so the tests can find it
- Return a value instead of only logging it
- Do not mutate inputs unless the challenge asks you to
Binary Search · editor
Code runs in an isolated Web Worker with a 3-second timeout — no DOM access, and it can never hang the page.