Problem
You get an integer array nums of length n. A peak is an item that is strictly larger than its neighbors. The neighbors of nums[i] are nums[i - 1] and nums[i + 1].
Think of nums[-1] and nums[n] as negative infinity. So the first item and the last item can also be peaks. No two neighbors have the same value.
Return the index of a peak. If the array has more than one peak, you can return the index of any peak. Your solution must run in O(log n) time.
Example 1
- Input:
- nums = [1,4,2]
- Output:
- 1
- Explanation:
- The item 4 is larger than 1 and 2.
Example 2
- Input:
- nums = [2,5,3,1,6,4]
- Output:
- 1
- Explanation:
- The index 4 is also correct, because 6 is larger than 1 and 4.
Example 3
- Input:
- nums = [9]
- Output:
- 0
- Explanation:
- The only item has no real neighbors, so it is a peak.
Constraints
- 1 <= nums.length <= 1000
- -2^31 <= nums[i] <= 2^31 - 1
- nums[i] != nums[i + 1] for all valid i
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Find First and Last Position of Element in Sorted Array
Coding · Array · Binary Search
- Find the Safest Path in a Grid
Coding · Array · Binary Search · Breadth-First Search
- 132 Pattern
Coding · Array · Binary Search · Monotonic Stack
- Avoid Flood in The City
Coding · Array · Binary Search · Greedy
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Meta
Leetcode 162. Find Peak Element
Reported Apr 21, 2026 · 26 source reports
JUNIOR, MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 3 records
Adobe
Find Peak Element
Reported date not specified · Source window: 30d
Source snapshot: Oct 20, 2026
Source frequency score: 100. This is not an interview probability.
View sourceAdobe
Find Peak Element
Reported date not specified · Source window: 3mo
Source snapshot: Oct 20, 2026
Source frequency score: 81.4. This is not an interview probability.
View sourceAdobe
Find Peak Element
Reported date not specified · Source window: 6mo