Search
⌘K
Get Premium
Leetcode 462. Minimum Moves to Equal Array Elements II
Given an integer array, find the minimum number of ±1 moves needed to make all elements equal — equivalently, choose a target value that minimizes the sum of absolute deviations. This is an L1-minimization problem whose optimal target is any median, so the answer is the sum of |nums[i] − median|.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.