python3
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
map = {}
for i in range(len(nums)):
complement = target - nums[i]
if complement in map: #如果当前值的互补值已经存在字典中
return [map[complement],i] #那么返回当前值和互补值的下标
map[nums[i]] = i #将当前的值存为key,下标存为value