标签:twosum nbsp for 个数 ret pre return print solution
class Solution(object): def twoSum(self, nums, target): dic = {} for i, num in enumerate(nums): if num in dic: return [dic[num], i] else: dic[target - num] = i x=Solution() l=[1,3,5,6] print(x.twoSum(l,9))
输出
[1, 3]
标签:twosum nbsp for 个数 ret pre return print solution
原文地址:https://www.cnblogs.com/sea-stream/p/10463703.html