双指针
注意要返回[],返回None会出错
class Solution: def FindNumbersWithSum(self, array, tsum): # write code here if not array : return [] first = 0 lenth = len(array) - 1 last = lenth while last > first: if array[first] + array[last] > tsum: last -= 1 elif array[first] + array[last] < tsum: first += 1 elif array[first] + array[last] == tsum: return [array[first],array[last]] return []