53. Is the Array Sorted?
Foundation1000 ms256 MBSolved by 0%
Print Yes if the array is sorted in non-decreasing order — each element
is greater than or equal to the one before it — and No otherwise.
Equal neighbours are fine. [1, 2, 2, 3] is sorted.
Constraints - `1 ≤ n ≤ 100000` - `-1000000 ≤ a[i] ≤ 1000000`
Input
The first line contains an integer n.
The second line contains n space-separated integers.
Output
Print exactly one word: Yes or No.
Input5
1 2 3 4 5
OutputYes
Noteis strictly ascending
Input4
1 3 2 4
OutputNo
Notehas one pair out of order in the middle
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution