My solution of Shinchan's good array in Java.
Shinchan's Good Array has the properties:
- Odd elements are in sorted order.
- Even elements are in sorted order.
- Odd elements occupy odd positions.
- Even elements occupy even positions.
- It has equal number of odd and even elements.
The following code takes the length of the array and the elements of the array and prints the sorted array along with the number of swaps needed to convert the array into a good array.