loading…
Write search(nums, target) for a sorted list. Return the index of target, or -1. Don't use .index() or bisect: the interviewer wants the loop.
search([-1, 0, 3, 5, 9, 12], 9) -> 4
search([-1, 0, 3, 5, 9, 12], 2) -> -1
Stuck on the idea itself? The binary search lesson walks through the pattern from scratch.