LeetCode solutions

1848. Sum of Unique Elements

My accepted Python solution to LeetCode problem 1848, Sum of Unique Elements, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 12.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 12.4MB, accepted 2025-12-24.

python
class Solution(object):
    def sumOfUnique(self, nums):
        from collections import Counter
        count = Counter(nums)
        return sum(num for num, cnt in count.items() if cnt == 1)

Source