162. Find Peak Element
Difficulty: Medium
A peak element is an element that is greater than its neighbors.
Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.
You may imagine that nums[-1] = nums[n] = -∞.
Example 1:
1 | **Input:** **nums** = `[1,2,3,1]` |
Example 2:
1 | **Input:** **nums** = `[`1,2,1,3,5,6,4] |
Note:
Your solution should be in logarithmic complexity.
Solution
Language: Java
1 | class Solution { |