Input: A[] = [2,1,5,3,4]
Output: 3
Explanation:
Operation 1: Swap (Arr[2], Arr[3]). Therefore, A[] modifies to {2, 1, 3, 5, 4}.
Operation 2: Swap(arr[3], arr[4]). Therefore, A[] modifies to {2, 1, 3, 4, 5}.
Operation 3: Swap (arr[0], arr[1]). Therefore, A[] modifies to {1, 2, 3, 4, 5}.
Therefore, the sequence of operations are: {2, 1, 5, 3, 4} ? {2, 1, 3, 5, 4} ? {2, 1, 3, 4, 5} ? {1, 2, 3, 4, 5}
Input: A[] = [2,5,1,3,4]
Output: -1