R3-二分查找
双指针简单题
python
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
#双指针法
i=0
j=len(numbers)-1
while i<j:
s=numbers[i]+numbers[j]
if s>target:
j-=1
elif s<target:
i+=1
else:
return i+1,j+1
return []