当前位置:网站首页>The sum of the unique elements of the daily question

The sum of the unique elements of the daily question

2022-07-05 05:42:00 A big pigeon

For integer array nums Element summation, which only occurs once in .

class Solution:
    def sumOfUnique(self, nums: List[int]) -> int:
        cnt = Counter(nums)
        return sum(k for k,v in cnt.items() if v == 1)

原网站

版权声明
本文为[A big pigeon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140620422368.html