problem
solution:
class Solution {
public:
int search(vector<int>& nums, int target) {
int left = , right = nums.size()-, mid = ;
while(left<=right)//errr...
{
mid = left + (right-left)/;
if(nums[mid]<target) left = mid+;
else if(nums[mid]>target) right = mid-;
else return mid;
}
return -;
}
};
参考
1. Leetcode_easy_704. Binary Search;
完