my-solution


  • 1
    J
    class Solution(object):
        def minMoves(self, nums):
            m, r = nums[0], 0
            for x in nums[1:]:
                if m > x:
                    m = x
            for x in nums:
                r += (x - m)
            return r
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.