Medium · Math

Minimum Moves to Equal Array Elements

Given an integer array nums of length n, return the minimum number of moves needed to make all elements equal, where one move adds 1 to n − 1 of the elements.

Examples

Example 1

[1,2,3] → 3

Output: 3 moves

Example 2

[1,1,2,4] → 4

Output: 4 moves

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Math problems