Mark As Completed Discussion

Good afternoon! Here's our prompt for today.

A peak element is an element that is strictly greater than its neighbors.

Consider that we are given a list of numbers, such as the following:

[1, 2, 3, 1]

Determine the peak element of this list, and return its index. If the array contains multiple peaks, return the index to any of the peaks.

Find Peak Element

Constraints

  • 1 <= nums.length <= 1000
  • -231 <= nums[i] <= 231 - 1
  • nums[i] != nums[i + 1] for all valid i.

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's our guided, illustrated walk-through.

How do I use this guide?

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.