Coding · Medium · Pro
Find a peak element (neighbors are smaller)
CodingBinary SearchSenior
Approach
- If
nums[mid] < nums[mid+1], peak lies on the right. - Else peak is on the left including mid.
- No need for the array to be globally sorted.
Java Solution
Java
public class PeakElement {…