classSolution:defFindNumbersWithSum(self, array, tsum):# write code here
l =0
r =len(array)-1while l < r:
s = array[l]+array[r]if s<tsum:
l+=1elif s==tsum:return[array[l],array[r]]else:
r-=1return[]
题目分析左右指针,找到第一个和为S的两个数,返回他俩。python代码class Solution: def FindNumbersWithSum(self, array, tsum): # write code here l = 0 r = len(array)-1 while l < r: s = array[l]+array[r] if s<tsum: