My Python way to solve it (48ms)

  • 3
    class Solution:
        # @param {integer[]} nums
        # @return {integer}
        def singleNumber(self, nums):
            a = set(nums)
            a = sum(a)*2
            singleNumber = a - sum(nums)
            return singleNumber

  • 1

    set function is not cheap,it takes time and extra space

Log in to reply

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