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]