Description

Given an array of integers arr, return true if and only if it is a valid mountain array with strictly increasing then strictly decreasing elements.

Examples

Input:arr = [0,3,2,1]
Output:true
Explanation:

Peak at index 1.

Input:arr = [0, 3, 2, 1]
Output:true
Explanation:

Peak at index 1 with strictly increasing [0,3] and strictly decreasing [3,2,1].

Input:arr = [1,2,3,2]
Output:true
Explanation:

Peak at index 2 with strictly increasing [1,2,3] and strictly decreasing [3,2].

Constraints

  • 1 ≤ arr.length ≤ 10^4

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!