34. 在排序数组中查找元素的第一个和最后一个位置——二分查找
class Solution {
public:
vector
int left = 0, right = nums.size() - 1, mid;
if(nums.size() == 0)return vector
if(nums.size() == 1)
return nums[0] == target ? vector
while(left <= right){
mid = (left + right) / 2;
if(nums[mid] == target)
共有 0 条评论