Find the minimum number of moves necessary to reorder an array so that all even numbers are at the front and all odd numbers are at the back.
A single move allows you to swap elements at any two indices in the array. For example, if the array is arr = [17, 4, 8], you can swap arr[0] and arr[2] to get arr = [8, 4, 17] in a single move.
Determine the minimum number of moves required to sort the array such that all even elements are at the beginning of the array and all odd elements are at the end of the array.
arr = [6, 3, 4, 5]
The following four arrays are valid custom-sorted arrays:
The most efficient sorting requires 1 move: swap the 4 and the 3.
Complete the function moves in the editor with the following parameter(s): int arr[n]: an array of positive integers
int: the minimum number of moves it takes to sort an array of integers with all even elements at earlier indices than any odd element
Note: The order of the elements within even or odd does not matter.