Skip to content

Commit c098567

Browse files
committed
sum of unique elements
1 parent e4d0ab9 commit c098567

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def sumOfUnique(self, nums):
3+
store = {}
4+
add = 0
5+
for i in nums:
6+
if store.get(i):
7+
value = store[i]
8+
if value == 1:
9+
add -= i
10+
store[i] += 1
11+
else:
12+
add += i
13+
store[i] = 1
14+
return add
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://leetcode.com/problems/sum-of-unique-elements/

0 commit comments

Comments
 (0)