#162 - Find Peak Element
A peak element is strictly greater than its neighbors. Given an integer array nums where nums[i] ≠ nums[i + 1], find any peak element and return its index. The array may contain multiple peaks. You must solve in O(log n) time. Assume nums[-1] = nums[n] = -∞.
| Input | Output |
|---|---|
nums = [1,2,3,1] | 2 |
nums = [1,2,1,3,5,6,4] | 5 (or 1) |