Problem 3422 · Medium

Minimum Operations to Make Subarray Elements Equal

Pick every run of k consecutive values and find the cheapest common target; the median of each run is the best choice.

Open the interactive visualisation