class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
a_dict = {}
for i in range (0, len(nums)):
x = nums[i]
y = target - nums[i]
if y in a_dict:
return (a_dict[y], i)
else:
a_dict[x] = i
No comments:
Post a Comment