vector<int> twoSum(vector<int>& nums, int target) {
int l=0;
int r=nums.size()-1;
vector<int> ans;
while(l<r){
if(nums[l]+nums[r]>target){
r--;
}else if(nums[l]+nums[r]==target){
ans.push_back(l+1);
ans.push_back(r+1);
break;
}else{
l++;
}
}
return ans;
}
标签:target,nums,int,back,vector,ans,LC167
From: https://www.cnblogs.com/lwx11111/p/16646037.html