Python solution


  • 3
    D
    class Solution(object):
    def singleNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        ret = {}
        result = -1;
        for i in nums:
            if i in ret:
                ret[i]=0;
            else:
                ret[i]=1;
    
        for v in ret.keys():
            if(ret[v]==1): 
                result = v
        
        return result;

Log in to reply
 

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