Derrangement Exercise (Contest)
Derrangement Exercise (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Derrangement Exercise (Contest) easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
You are given an array A of size N. In one move, you can swap any two elements of this array. Find out whether you can make this array strictly increasing or not after any (possibly 0) number of moves. Input The first line of the input contains a single integer N. The second line of the input contains N space seperated integers.
Constraints: 1 <= N <= 105 1 <= Ai <= 106 Output Print "YES", if you can make the array strictly increasing, else print "NO", without the quotes. Example Sample Input: 5 5 9 4 5 3
Sample Output: NO
Explaination: After any number of moves, you cannot make this array strictly increasing.
link: