Problem Statement
A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks.
Approach
Binary search. If nums[mid] < nums[mid+1], we are on an uphill slope, so the peak must be to the right (left = mid + 1). Otherwise, we are on a downhill slope or at a peak, so search left (right = mid).
Time & Space Complexity
Time complexity is O(log n). Space complexity is O(1).
