class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: d={} for i ,x in enumerate(nums): another_num=target-x if another_num in d: return [d[another_num],i] d[x]=i return None
原文:https://www.cnblogs.com/liuxiangyan/p/14589387.html