leetcode167 python3 72ms 两数之和,有序数组

class Solution:
    def twoSum(self, numbers, target):
        """
        :type numbers: List[int]
        :type target: int
        :rtype: List[int]
        """
        d = {}
        for i in range(0, len(numbers)):
            if target - numbers[i] not in d.keys():
                d[target - numbers[i]] = i
            if numbers[i] in d.keys() and i != d[numbers[i]]:
                return [d[numbers[i]]+1, 1+i]
                
                   
        
posted @ 2018-08-09 14:59  一条图图犬  阅读(213)  评论(0编辑  收藏  举报