Binary Search
Medium · Algorithms
nums is sorted in non-decreasing order. Return the index of target, or -1 if it is missing. Use binary search: O(log n) comparisons, not a linear scan.
Write Search(nums, target). If target appears more than once, any of its indexes is accepted — the tests use unique values.
Next: Stack