#3505
Minimum Operations to Make Elements Within K Subarrays Equal
international master · 2040 · lc hard +32 · 27.8% accepted · 59 likes · top 6%
Description
Given integer array nums and integers x and k, each operation increments or decrements any element by 1.
Find the minimum number of operations needed so that nums contains at least k non-overlapping subarrays of length exactly x where all elements in each subarray are identical.
Code
1
2
3