Given an array nums of distinct integers, determine the minimum number of adjacent swaps required to rearrange the array such that the parity of the elements alternates throughout the array.
An array has alternating parity if no two adjacent elements have the same parity.
Return the minimum number of adjacent swaps needed to achieve this configuration, or return
Constraints:
nums.length
nums[i]
All elements in nums are distinct.
Given an array nums of distinct integers, determine the minimum number of adjacent swaps required to rearrange the array such that the parity of the elements alternates throughout the array.
An array has alternating parity if no two adjacent elements have the same parity.
Return the minimum number of adjacent swaps needed to achieve this configuration, or return
Constraints:
nums.length
nums[i]
All elements in nums are distinct.