# class Solution(object):
# def singleNum(self,nums):
# for i in nums:
# n = nums.count(i)
# if n == 1:
# return i
#
# s=Solution()
# print(s.singleNum([1,2,2,3,3]))
#
#
# nums=[2,2,1,1,1,3]
# {1:3,2:2,3:1}
from collections import Counter
class Solution(object):
def singleNum(self,nums):
dict_nums = dict(Counter(nums))
nums_list = dict_nums.keys()
for i in nums_list:
if dict_nums[i]==1:
return i
网友评论