leetcode1 python3 76ms twoSum 360面试题
class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
d = {}
for i in range(0, len(nums)):
if target - nums[i] not in d.keys():
d[target - nums[i]] = i
if nums[i] in d.keys() and i !=d[nums[i]]:
return [d[nums[i]], i]