Simple Python Solution


  • 0
    K
        def minMoves2(self, nums):
            nums.sort()
            count = 0
            for num in nums:
                count += abs(num - nums[len(nums)//2])
            return count
    

Log in to reply
 

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