167. Two Sum II - Input array is sorted

xiaoxiao2021-02-28  115

class Solution(object): def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ d = dict() for index,value in enumerate(numbers): if target-value in d: return [d[target-value]+1,index+1] d[value] = index

enumerate():

>>> for index,value in enumerate([1,2,3]) >>>   print 0,1 1,2 2,3
转载请注明原文地址: https://www.6miu.com/read-40608.html

最新回复(0)