这次的III仅仅比2多了一个要计算的东西,返回的也是列表,有Counter在也很简单。代码如下:
class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
list1 = []
from collections import Counter
a = Counter(nums)
for i in a.keys():
if a[i] == 1:
list1.append(i)
return list1