3736. Minimum Moves to Equal Array Elements III
约 1 分钟
LeetCode 每日一题:Minimum Moves to Equal Array Elements III
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.
Constraints:
1 <= nums.length <= 1001 <= nums[i] <= 100
思路
python
class Solution:
def minMoves(self, nums: List[int]) -> int:
max_num = max(nums)
return sum((max_num-num for num in nums))系列每日一题 →
标签看图写话