Skip to content

Practice Find the Peaks

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2951
LeetCode Problem

Find the Peaks

Problem Statement

Return the indices of elements in mountain that are strictly greater than both immediate neighbors. The first and last elements cannot be peaks. Indices may be returned in any order.

Source: Find the Peaks on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
mountain = [2,4,4]
Output
[]

# Example 2

Input
mountain = [1,4,3,8,5]
Output
[1,3]

Constraints

3 <= mountain.length <= 100
1 <= mountain[i] <= 100

Related LeetCode Problems

Practice more problems similar to Find the Peaks.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.