Let me explain why x = minNum + m our goal is :increment minNum to be equal to maxNum
- No matter how many add operations are executed,the goal won't change.
- Every time we do the add operation,the min number in the array must participate in.
- After an add operation,the minNum is still the min number
So the minNum participate in every add operation So x = minNum + m
class Solution:
def minMoves(self, nums: List[int]) -> int:
m = sum(nums) - min(nums) * len(nums)
return m