#C11187. Determine Array Order
Determine Array Order
Determine Array Order
You are given an array of integers. Your task is to determine whether the array is in strictly increasing order, strictly decreasing order, or neither.
An array is said to be strictly increasing if for every consecutive pair of elements, the earlier element is less than the later element. Similarly, it is strictly decreasing if for every consecutive pair, the earlier element is greater than the later element. If neither of these conditions holds, the output should be Neither
.
Note: The input format is such that the first line contains an integer n, representing the number of elements in the array, followed by a line with n space-separated integers. Your program should output one of the strings: Increasing
, Decreasing
, or Neither
.
The mathematical definitions can be written in latex as follows:
\( \text{Strictly Increasing: } \forall i \in \{1,2,\dots,n-1\},\; a_i < a_{i+1} \)
\( \text{Strictly Decreasing: } \forall i \in \{1,2,\dots,n-1\},\; a_i > a_{i+1} \)
inputFormat
The first line contains an integer n (1 ≤ n ≤ 105), representing the number of elements in the array.
The second line contains n space-separated integers.
outputFormat
Output a single line containing one of the following strings: Increasing
, Decreasing
, or Neither
depending on the order of the array.
5
1 2 3 4 5
Increasing