leetcode 167 两数之和2,输入有序数组
解题思路:双指针碰撞
class Solution { public int[] twoSum(int[] numbers, int target) { int len = numbers.length; int start = 0; int end = len - 1; while(start<end){ if(numbers[start]+numbers[end]>target){ --end; }else if(numbers[start]+numbers[end]<target){ ++start; }else{ return new int[]{start+1,end+1}; } } return null; } }