simple O(n) python solution

  • 1

    The answer is actually to sum up the differences of each element w/ the minimum element

        def minMoves(self, nums):
            min_val = min(nums)
            return sum([v-min_val for v in nums])

Log in to reply

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