Skip to content

Commit 1df529b

Browse files
authored
Create sum-of-unique-elements.py
1 parent fac4c6d commit 1df529b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Python/sum-of-unique-elements.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
import collections
5+
6+
7+
class Solution(object):
8+
def sumOfUnique(self, nums):
9+
"""
10+
:type nums: List[int]
11+
:rtype: int
12+
"""
13+
return sum(x for x, c in collections.Counter(nums).iteritems() if c == 1)

0 commit comments

Comments
 (0)