9 lines
270 B
Python
9 lines
270 B
Python
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 []
|