136. Single Number

xiaoxiao2021-02-28  91

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不同的剩下了

转载请注明原文地址: https://www.6miu.com/read-43570.html

最新回复(0)