Problem 3505 · Hard

Minimum Operations to Make Elements Within K Subarrays Equal

One operation moves any element of nums up or down by 1. Find the fewest operations that leave at least k non-overlapping stretches of exactly x positions, each stretch holding one repeated value.

Open the interactive visualisation