class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
int start;
int end;
start=0;
end=nums.size()-1;
while(start<=end)
{
int mid=(start+end)/2;
if(nums[mid]==target)
return mid;
else if(nums[mid]<target)
start=mid+1;
else
end=mid-1;
}
return start;
}
};
35. Search Insert Position
最新推荐文章于 2024-09-29 10:07:17 发布