Search
⌘K

Leetcode 3107. Minimum Operations to Make Median of Array Equal to K

Find the minimum number of ±1 operations to make the array's median equal to k. After sorting, only elements on the median side that lie on the "wrong" side of k must be moved, so the answer is the sum of their distances to k.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.