</>OfferRetriever
DashboardDiscuss
NEW

Spring Hire Sale

Limited Time Deal: Unlock all premium questions for over 30% off

$10.42$7.08

08

:

04

:

55

:

59

Get this deal
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. ...