easyDivide & conquer1 bug
Binary Search
Search works for most items, but the last product in the catalog is never found.
binarySearch(arr, target) returns the index of target in a sorted array, or -1.
Fix the code so every test passes. Keep the function name binarySearch.
Test cases
- binarySearch([1,3,5,8,10,12,16], 16) → 6
- binarySearch([1,3,5,8,10], 1) → 0
- binarySearch([7], 7) → 0
- binarySearch([1,3,5], 4) → -1
Hints
each hint costs XPStuck? Hints go from a nudge to the exact fix.