Medium · Binary Search

Find Peak Element

Given an integer array nums in which adjacent values differ, return the index of any peak: an element strictly greater than its neighbors, where positions outside the array count as −∞.

Examples

Example 1

[1,2,1,3,5,6,4]

Output: index 5 (value 6)

Example 2

[1,2,3,1]

Output: index 2 (value 3)

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Binary Search problems