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 how we would solve this problem...

How do I use this guide?