Finish problem 0001-two-sum
This commit is contained in:
@@ -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 []
|
||||
Reference in New Issue
Block a user