Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Find Peak Element

Medium Binary Search

A peak element is strictly greater than its neighbours (treat the outside as negative infinity). Given an array where adjacent elements are different, print the index of any peak in O(log n).

Constraints

1 <= n <= 1000 -2^31 <= nums[i] <= 2^31 - 1

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.