Problem 3587 · Medium

Minimum Adjacent Swaps to Alternate Parity

Each swap moves one even value and one odd value by a step, so the cheapest alternating pattern is the one where the evens (or odds) move least.

Open the interactive visualisation