Problem 2340 · Medium

Minimum Adjacent Swaps to Make a Valid Array

Slide the leftmost minimum to the front, then the rightmost maximum to the back, counting each adjacent swap.

Open the interactive visualisation