#C9034. Valid Mountain Array
Valid Mountain Array
Valid Mountain Array
In this problem, you are given an array of integers. Your task is to determine whether the array represents a valid mountain array. A mountain array is defined as an array where:
- The length of the array is at least 3.
- There exists an index ( i ) (( 0 < i < n-1 )) such that:
- The sequence ( arr[0] ) to ( arr[i] ) is strictly increasing (i.e. ( arr[j] < arr[j+1] ) for all ( 0 \le j < i ));
- The sequence from ( arr[i] ) to ( arr[n-1] ) is strictly decreasing (i.e. ( arr[j] > arr[j+1] ) for all ( i \le j < n-1 )).
Print "True" if the given array is a valid mountain array, otherwise print "False".
Note: The input is read from standard input and the output should be written to standard output.
inputFormat
The first line contains a single integer ( n ) (the number of elements in the array). The second line contains ( n ) space-separated integers representing the elements of the array.
outputFormat
Output a single word: "True" if the array forms a valid mountain, otherwise "False".## sample
4
0 3 2 1
True