162. Find Peak Element
https://leetcode.com/problems/find-peak-element/
Problem
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:
Example 2:
Follow up: Your solution should be in logarithmic complexity.
Solution
#binarysearch
#important
Last updated
Was this helpful?