Input: N = 4, arr[] = [4, 3, 2, 5]
Output: true
Explanation: In the given array, perform the following operations:
Swap arr[0] and arr[1] updated array: [-3, -4, 2, 5]
Swap arr[1] and arr[2] updated array: [-3, -2, 4, 5]
Swap arr[1] and arr[0] updated array: [2, 3, 4, 5]
The array is sorted in non-decreasing order and the elements are all positive.
Input: N = 4, arr[] = [3, 3, 2, 2]
Output: true
Explanation: In the given array, perform the following operations :
Swap arr[0] and arr[2] updated array: [-2, 3, -3, 2]
Swap arr[1] and arr[3] updated array: [-2, -2, -3, -3]
Swap arr[1] and arr[0] updated array: [2, 2, -3, -3]
Swap arr[2] and arr[3] updated array: [2, 2, 3, 3]
The array is sorted in non-decreasing order and the elements are all positive.
Input: N = 5, arr[] = [1, 2, 3, 5, 4]
Output: false
Explanation: There is no way to sort the array such that it follows all the mentioned conditions.