Given a sorted array of integers and a target, return the index or -1. Must be O(log n).
Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4
Topics: binary-search, arrays
Asked by: Amazon, Google, Meta, Microsoft, Apple
Time complexity: O(log n). Space complexity: O(1).