class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
hash_map = {}
for i, num in enumerate(nums):
complement = target - num # 计算目标值需要的差值
if complement in hash_map: # 查找哈希表中是否存在这个差值
return [hash_map[complement], i] # 找到匹配项,返回两个索引
hash_map[num] = i