Problem 1703 · Hard

Minimum Adjacent Swaps for K Consecutive Ones

Shift each window of k ones toward its median one so the cost becomes a sum of absolute distances.

Open the interactive visualisation