453 Minimum Moves to Equal Array Elements
Input:
[1,2,3]
Output:
3
Explanation:
Only three moves are needed (remember each move increments two elements):
[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]def minMoves(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
m = min(nums)
dec_2_zero = sum(nums) - m
over_shoot = (len(nums)-1) * m
return dec_2_zero - over_shootLast updated