Valid Mountain Array

Given an array `arr`, return `true` if and only if it is a valid mountain array. An array is a valid mountain if it strictly increases to a peak (not at ends) and then strictly decreases.

Input Format

arr = array of integers

Output Format

true if arr is a valid mountain array, false otherwise

Constraints

Examples

Example 1:

Input:

arr = [0,3,2,1]

Output:

true

Explanation:

Increases to 3 then decreases.

Example 2:

Input:

arr = [3,5,5]

Output:

false

Explanation:

Plateau at peak not strictly increasing.

Example 3:

Input:

arr = [0,1,2,3]

Output:

false

Explanation:

No decreasing part.

Loading...
Valid Mountain Array - Two Pointers DSA Problem