Tap here to switch tabs
Problem
Submissions

Problem: Minimum Moves to Equal Array Elements

med
30 min
Try to solve the Minimum Moves to Equal Array Elements problem.

Statement

Given an integer array nums of length n, you can perform the following operation any number of times.

In one move, choose exactly n−1n - 1 elements of nums and increment each chosen element by 11.

Return the minimum number of moves required to make all elements in nums equal.

Note: The result is guaranteed to fit in a 3232 bit integer.

Constraints:

  • n == nums.length

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Moves to Equal Array Elements

med
30 min
Try to solve the Minimum Moves to Equal Array Elements problem.

Statement

Given an integer array nums of length n, you can perform the following operation any number of times.

In one move, choose exactly n−1n - 1 elements of nums and increment each chosen element by 11.

Return the minimum number of moves required to make all elements in nums equal.

Note: The result is guaranteed to fit in a 3232 bit integer.

Constraints:

  • n == nums.length

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9