3422. Minimum Operations to Make Subarray Elements Equal
ArrayHash TableMathSliding WindowHeap (Priority Queue)
Hints
Hint 1
It can be proven that for each subarray of size
k, one optimal common value is the median.Hint 2
Use 2 multisets to maintain the median dynamically.
Hint 3
Calculate the sums of the 2 multisets dynamically to accelerate the answer calculation.
Preparing judge…