class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ d = {} for i, num in enumerate(nums): a = nums[i] b = target - a if b in d: return [d[b], i] else: d[a] = i