A peak element is one greater than its neighbors. Given an array nums, find a peak element and return its index. The array may have multiple peaks; return any peak.
Binary search: if nums[mid] < nums[mid+1], there must be a peak on the right side. Otherwise there is a peak at mid or to the left.
- lo=0, hi=n-1.
- If nums[mid] < nums[mid+1]: peak is to the right, lo=mid+1.
- Else: peak is at mid or left, hi=mid.
- When lo==hi, that is the peak index.
- Time Complexity: O(log N)
- Space Complexity: O(1)