Input: arr1[] = {5, 7, 8, 2, 10, 13}, arr2[] = {8, 5, 2, 7, 13, 10}
Output: Yes
Explanation:
At first, swap 10 and 13 so arr1[] = [5, 7, 8, 2, 13, 10].
Now, swap 7 and 8 so arr1[] = [5, 8, 7, 2, 13, 10].
Now, swap 5 and 8 so arr1[] = [8, 5, 7, 2, 13, 10].
Now, swap 7 and 2 so arr1[] = [8, 5, 2, 7, 13, 10] = arr2[].
In each operation, we swap adjacent elements with different parity.
Input: arr1[] = {0, 1, 13, 3, 4, 14, 6}, arr2[] = {0, 1, 14, 3, 4, 13, 6}
Output: No
Explanation:
It is not possible to swap 13, 14 because they are not adjacent.