My Python way to solve it (48ms)


  • 3
    J
    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
    F

    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.