#C9714. One Removal to Achieve a Strictly Increasing Sequence
One Removal to Achieve a Strictly Increasing Sequence
One Removal to Achieve a Strictly Increasing Sequence
Given an array of integers, determine whether it is possible to obtain a strictly increasing sequence by removing at most one element from the array. A sequence \(a_1, a_2, \ldots, a_n\) is strictly increasing if \(a_i < a_{i+1}\) for all valid indices.
Your task is to implement a program that reads the array from the standard input and prints YES
if it is possible to achieve a strictly increasing sequence by removing no more than one element, and NO
otherwise.
Note: Removing an element means that the order of the remaining elements is preserved.
inputFormat
The first line of input contains a single integer (n), the number of elements in the array. The second line contains (n) space-separated integers, representing the array elements.
outputFormat
Output a single line containing YES
if the array can be transformed into a strictly increasing sequence by removing at most one element. Otherwise, output NO
.## sample
5
3 5 2 7 8
YES
</p>