Input: A[] = {1, 2, 5 ,6}
Output: YES
Explanation: One of the possible sequence of operations is listed below:
Move 1: Select i=2, j=4.
A[2]= 3, A[4]= 5 to get {1, 3, 5, 5}
Move 2: Select i=2, j=4.
A[2]= 4, A[4]= 4 to get {1, 4, 5, 4}
Move 3: Select i=1, j=3.
A[1]= 2, A[3]= 4 to get {2, 4, 4, 4}
Move 4: Select i=1, j=3.
A[1]= 3, A[3]= 3 to get {3, 4, 3, 4}
Here, all the odd elements are equal and all the even elements are equal. Also, the parity at each index is preserved.
Input: A[] = {1, 1, 2, 4}
Output: NO
Explanation: It is not possible to satisfy all the given conditions using any number of operations.