#K716. Mountain Array Validation
Mountain Array Validation
Mountain Array Validation
You are given multiple test cases. In each test case, you are provided an integer array. Your task is to determine whether the given array forms a valid mountain array.
A valid mountain array meets the following conditions:
- The array must contain at least 3 elements.
- There exists an index \(i\) (with \(0 < i < n-1\)) where the array strictly increases up to \(i\) and then strictly decreases after \(i\).
In other words, for an array \(a = [a_0, a_1, \dots, a_{n-1}]\) to be a mountain array, there must be an index \(i\) such that: \[ a_0 < a_1 < \cdots a_{i+1} > \cdots > a_{n-1}, \] with \(0 < i .
inputFormat
The first line of input contains a single integer (T), the number of test cases. Each test case consists of two lines:
- The first line contains an integer (N), the length of the array.
- The second line contains (N) space-separated integers representing the array elements.
outputFormat
For each test case, output a single line containing "Mountain Array" if the array is a valid mountain array, or "Not a Mountain Array" otherwise.## sample
5
6
0 1 2 3 2 1
4
1 2 3 4
3
2 3 1
5
0 3 2 4 1
4
3 5 4 1
Mountain Array
Not a Mountain Array
Mountain Array
Not a Mountain Array
Mountain Array
</p>