Skip to main content
Back to problems
Leetcode
Medium
Arrays
Valid Mountain Array

Determine whether an array rises strictly to a single peak and then falls strictly, forming a mountain shape.

Acceptance 0%
Problem Statement

Valid Mountain Array

Given an integer array arr, determine whether it forms a valid mountain array.

An array is a valid mountain array if:

  • its length is at least 3,
  • there exists an index peak with 0 < peak < n - 1,
  • the values strictly increase from arr[0] to arr[peak], and
  • the values strictly decrease from arr[peak] to arr[n - 1].

Return true if the array is a valid mountain array, otherwise return false.

A valid mountain must have exactly one peak and no plateaus.

Input Format

  • An integer array arr.

Output Format

  • Return true if arr is a valid mountain array; otherwise return false.

Constraints

  • 3n3 \le n
  • The array must have exactly one peak.
  • Adjacent values must be strictly increasing before the peak and strictly decreasing after the peak.
Examples
Sample cases returned by the problem API.

Example 1

Input

arr = [0,3,2,1]

Output

true

Explanation

The array strictly increases from 0 to 3, then strictly decreases from 3 to 1, with a single peak at index 1.

Example 2

Input

arr = [3,5,5]

Output

false

Explanation

The values do not strictly increase and then strictly decrease because 5 is repeated, creating a plateau.

Show 1 more example

Example 3

Input

arr = [2,1]

Output

false

Explanation

The array is too short to form a mountain.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.