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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 12.4MB, accepted 2025-12-24.
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)