Skip to content

Commit 5c02dea

Browse files
committed
feat: solve new question
1 parent 3f88173 commit 5c02dea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

two-sum/main.py

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

0 commit comments

Comments
 (0)