CodeOath
← All problems

Binary Search

Easy
binary-search

Return the index of target in a sorted, distinct array, or -1. Must be O(log n).

Example:

Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4