双指针遍历即可:
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
lens = len(numbers)
start = 0
stop = lens - 1
while(stop > start):
while(numbers[stop] + numbers[start] <= target):
if numbers[stop] + numbers[start] == target:
return [start + 1, stop + 1]
start += 1
stop -= 1
return None