class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
if len(nums)<=1:
return false
buff_dict={} //使用
for i in range(len(nums)):
if nums[i] in buff_dict:
return [buff_dict[nums[i]],i]
else:
buff_dict[target-nums[i]]=i
leetcode刷题: twosum
最新推荐文章于 2020-02-20 18:03:19 发布