Problem 3994 · Medium

Minimum Adjacent Swaps to Partition Array

Sort values into three bands with adjacent swaps, keeping the order inside each band free. Each value only has to pass the earlier values that belong to a higher band, and counting those gives the answer.

Open the interactive visualisation