Company: Publicis Sapient_27sept
Difficulty: medium
Minimum Swaps to Arrange Even Before Odd Problem Description You are given an array of integers. In one move, you can swap the elements at any two indices. Your task is to rearrange the array so that: All even numbers appear before all odd numbers. The relative order among even numbers or among odd numbers does not matter. You need to determine the minimum number of moves required to achieve this arrangement. Examples Example 1: Input: arr = [4, 13, 10, 21, 20] Output: 1 Explanation: Array = [13, 10, 21, 20] Swap 13 (odd) with 20 (even) -> [20, 10, 21, 13]. Only 1 move is required. Example 2: Input: arr = [5, 8, 5, 11, 4, 6] Output: 2 Explanation: Array = [8, 5, 11, 4, 6] Swap 5 (odd) with 4 (even) -> [8, 4, 11, 5, 6]. Swap 11 (odd) with 6 (even) -> [8, 4, 6, 5, 11]. A valid arrangement is obtained in 2 moves, which is minimal. Constraints 2 1 The array always contains at least one even and one odd element.