Spring Hire Sale
Limited Time Deal: Unlock all premium questions for over 30% off
$10.42$7.08
08
:
03
:
10
:
51
Back to Dashboard
Evens Before Odds
Medium
You are given an integer array nums. Rearrange nums so that all even numbers appear before all odd numbers. The relative order of even or odd numbers among themselves does not matter.
Return the minimum number of swaps needed to achieve this arrangement. A single swap exchanges the values at any two distinct indices. If the array is already arranged with all evens before all odds, return 0. ...