#C6956. One Change to Make Array Strictly Increasing
One Change to Make Array Strictly Increasing
One Change to Make Array Strictly Increasing
You are given an array of n integers. You are allowed to modify at most one element in the array. Determine whether it is possible to transform the given array into a strictly increasing sequence (i.e. each element is greater than the previous one) by changing at most one element.
More formally, for an array \(a_1, a_2, \ldots, a_n\), check if there exists at most one index \(i\) such that by replacing \(a_i\) with some integer \(x\), the following condition holds:
[ a_1 < a_2 < \cdots < a_{i-1} < x < a_{i+1} < \cdots < a_n ]
If it is possible, output YES
; otherwise, output NO
.
inputFormat
The input is given via standard input (stdin) with the following format:
- The first line contains a single integer T representing the number of test cases.
- For each test case:
- The first line contains a single integer N, the size of the array.
- The next line contains N space-separated integers representing the array.
outputFormat
For each test case, output a single line to the standard output (stdout) containing either YES
or NO
depending on whether it is possible to make the array strictly increasing by changing at most one element.
1
4
1 2 3 4
YES
</p>