Skip to content

Commit 7863575

Browse files
committed
two sum solution
1 parent f291ae8 commit 7863575

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

two-sum/yayyz.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def twoSum(self, nums: List[int], target: int) -> List[int]:
3+
hashmap = {}
4+
for i, num in enumerate(nums):
5+
complement = target - num
6+
if complement in hashmap:
7+
return [hashmap[complement], i]
8+
hashmap[num] = i

0 commit comments

Comments
 (0)