Company: Publicis Sapient_26march
Difficulty: medium
Moves to Segregate Even and Odd Problem Description You are given an array a of n positive integers, indexed from 0 to n - 1 . A move picks any two indices i and j and swaps the elements stored at them. The two indices do not have to be adjacent. For example, if a = [17, 4, 8] , one move can swap a[0] = 17 and a[2] = 8 to give a = [8, 4, 17] . An array is custom-sorted when every even element sits at a smaller index than every odd element -- that is, all the even elements come first and all the odd elements come last. The order of the elements within the even block does not matter, and neither does the order within the odd block. For example, if a = [6, 3, 4, 5] , then exactly these four arrays are custom-sorted: [6, 4, 3, 5] [4, 6, 3, 5] [6, 4, 5, 3] [4, 6, 5, 3] Complete the function moves . It must return the minimum number of moves needed to turn a into a custom-sorted array. The function moves has the following parameter: a : the array of positive integers, a[0] through a[n-1] Inp