第20636题 判断题
判断给定lowerBound代码能否正确查找升序数组中第一个大于等于x的元素位置

若数组a已按升序排列,判断下述代码是否可以正确实现在a中查找第一个大于等于x的元素的位置:

int lowerBound(vector<int>& a,int x){
  int l=0, r=a.size();
  while(l < r) {
   int mid = (l + r) / 2;
   if( a[mid] >= x) r = mid;
   else l = mid + 1;
  }
  return l;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析