Python dictionary


  • 0
    D
    class Solution(object):
        def singleNumber(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            map = {}
            if ( nums == [] ):
                return -1
            for d in nums:
                if ( d in map):
                    del map[d]
                else:
                    map[d] = 1
            return list(map.keys())[0]
    

Log in to reply
 

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