class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dic= collections.Counter(nums)
for i in nums:
if dic[i]==1:
return i
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ return reduce(lambda x, y: x ^ y, nums)
相同的为0不同的剩下了