Search
⌘K

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|.

Asked at:

PayPal


Question Timeline

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

Early January, 2026

PayPal

Senior

Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

Comments

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