python 3-liner


  • 0
    X
    from collections import Counter
    
    class Solution(object):
        def minMoves(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            c = Counter(nums)
            min_num = min(c.iterkeys())
            return sum([(key-min_num) * count for key,count in c.iteritems()])
    

Log in to reply
 

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