November 3Easy
Minimum moves to equal array elements iii
- Array
- Math
Problem
You are given an integer array nums.
In one move, you may increase the value of any single element nums[i] by 1.
Return the minimum total number of moves required so that all elements in nums become equal.
Solution
class Solution:
def minMoves(self, nums: List[int]) -> int:
return len(nums) * max(nums) - sum(nums)