Skip to main content
PreparationZone Logo
PreparationZone
Back to Coding

Coding · Medium · Pro

Find a peak element (neighbors are smaller)

CodingBinary SearchSenior
Model answerPreview

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 {…