Given an array of integers arr, return true if and only if it is a valid mountain array: arr.length >= 3, and there is some index i with 0 < i < arr.length - 1 such that arr[0] < arr[1] < ... < arr[i] and arr[i] > arr[i + 1] > ... > arr[arr.length - 1].
Given an array of integers arr, return true if and only if it is a valid mountain array: arr.length >= 3, and there is some index i with 0 < i < arr.length - 1 such that arr[0] < arr[1] < ... < arr[i] and arr[i] > arr[i + 1] > ... > arr[arr.length - 1].
Example 1:
Input: {"arr":[2,1]}
Output: false
Constraints:
1≤arr.length≤104
0≤arr[i]≤104
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"arr":[2,1]}
One climber starts at the left end (i = 0) and walks uphill; another starts at the right end (j = 1) and walks uphill toward the left.