Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find Peak Element

XPChallenge Points: 20
levelLevel: Medium

You are given a 0-indexed integer array nums.
A peak element is an element that is strictly greater than its immediate neighbors.
Your task is to find the index of any peak element in the array.
If multiple peaks exist, return the index of any one of them.
Assume that:
• nums[-1] = nums[n] = -∞ (virtual boundaries)
• You must design an algorithm that runs in O(log n) time complexity.

Example 1:

Input: nums = [2, 5, 3, 1]

Output: 1

Example 2:

Input: nums = [1, 4, 6, 3, 2, 7, 5]

Output: 2

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result