int search(vector<int>& nums, int target) {
int l=0;
int r=nums.size()-1;
cout<<r<<endl;
int mid;
while(l<r){
mid=(l+r)/2;
if(nums[mid]<target){
l=mid+1;
}else if(nums[mid]>target){
r=mid;
}else{
return mid;
}
}
return -1;
}
标签:二分,return,nums,int,leetcode704,mid,查找
From: https://www.cnblogs.com/lwx11111/p/16640640.html