Skip to content

Commit cd12a2c

Browse files
faster
1 parent dee62c7 commit cd12a2c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Two Sum.py

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

0 commit comments

Comments
 (0)