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]
leetcode1 python3 76ms 360面试题
猜你喜欢
转载自www.cnblogs.com/theodoric008/p/9420655.html
今日推荐
周排行