← All problemsSign in

3587. Minimum Adjacent Swaps to Alternate Parity

LeetCodeArrayGreedyOpen on judge ↗

You are given an array nums of distinct integers. In one operation, you can swap any two adjacent elements in the array. An arrangement of the array is considered valid if the parity of adjacent elements alternates, meaning every pair of neighboring elements consists of one even and one odd number. Return the minimum number of adjacent swaps required to transform nums into any valid arrangement

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start