Skip to content

Commit 55d5072

Browse files
committed
feat: Add Two Sum Solution #219
1 parent 075e575 commit 55d5072

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

two-sum/river20s.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution(object):
2+
def twoSum(self, nums, target):
3+
"""
4+
:type nums: List[int]
5+
:type target: int
6+
:rtype: List[int]
7+
"""
8+
seen = {}
9+
for i, num in enumerate(nums):
10+
comp = target - num
11+
if comp in seen:
12+
return seen[comp], i
13+
if num not in seen:
14+
seen[num] = i
15+
return None
16+

0 commit comments

Comments
 (0)