!!!题目链接!!!
Solution:
class Solution {
public:
vector<int> twoSum(vector<int>& numbers, int target) {
int le = 0;
int ri = numbers.size()-1;
vector<int> result(0);
while(true)
{
if(numbers[le] + numbers[ri] > target)
{
ri--;
}else if(numbers[le] + numbers[ri] < target){
le++;
}else if(numbers[le] + numbers[ri] == target)
{
result.push_back(le+1);
result.push_back(ri+1);
break;
}
}
return result;
}
};