Python Solution using a Set and not using bit manipulation


  • 0
    D
    def singleNumber(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            rtnSet = set()
            for num in nums:
                if num not in rtnSet:
                    rtnSet.add(num)
                else:
                    rtnSet.remove(num)
            return rtnSet.pop()
    

Log in to reply
 

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