ids, sorted in ascending order with no repeats. You need to find where the number wanted is stored.
Return the index of wanted in ids (0-based), or -1 if it is not there.
Scanning the whole list is too slow: your solution must run in O(log n).ids=[-7, 2, 15, 40, 41, 300], wanted=40 → 3
Number 40 sits at index 3.
ids=[-7, 2, 15, 40, 41, 300], wanted=16 → -1
There is no 16 in the list, so the answer is -1.
ids=[5], wanted=5 → 0
ids[i] are distinct and strictly increasingids=[-7, 2, 15, 40, 41, 300], wanted=40
3
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.