class Solution {
public int[] twoSum(int[] numbers, int target) {
int i=0,j=numbers.length-1;
while(numbers[i]+numbers[j]!=target){
if(numbers[i]+numbers[j]<target)
++i;
else
--j;
}
return new int[]{i+1,j+1};
}
}
leetcode No.167两数之和2 输入有序数组
猜你喜欢
转载自blog.csdn.net/qq_33399567/article/details/88995252
今日推荐
周排行