Finish problem 0001-two-sum

This commit is contained in:
Johan Sandoval
2026-07-21 19:01:26 -05:00
parent 78725a4eed
commit 2476821049
2 changed files with 22 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
class Solution:
def twoSum(self, nums: list[int], target: int) -> list[int]:
hashmap = {}
for i, n in enumerate(nums):
if target - n in hashmap:
return [hashmap[target - n], i]
hashmap[n] = i
return []