第39011题 单选题
给定一个长度为$n$的有序数组nums,其中可能包含重复元素。下面的函数返回数组中某个元素target的 左边界,若数组中不包含该元素,则返回−1。例如在数组nums = [5,7,7,8,8,10]中查找target=8,函数返回$8$在数组中的左边界的索引为$3$。则横线上应填写的代码为( )。
int getLeftBoundary(vector<int>& nums, int target) {
    int left = 0;
    int right = nums.size() - 1;

    while (left < right) {
        int middle = left + ((right - left) / 2);
        if (target <= nums[middle])
            ________________________________ // 在此处填入代码
        else
            left = middle+1;
    }

    return nums[left]==target?left:-1;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析