leetcode:唯一元素的和
作者:互联网
src:
class Solution:
def sumOfUnique(self, nums: List[int]) -> int:
ans = 0
mp = defaultdict(int)
for num in nums:
mp[num] += 1
for num in mp:
if mp[num] == 1:
ans += num
return ans
快乐初六
标签:defaultdict,nums,int,元素,唯一,num,mp,ans,leetcode 来源: https://blog.csdn.net/weixin_40986490/article/details/122796076