第11940题 单选题
给定在升序数组nums中查找目标值target的Python二分查找代码,补全其中空缺的mid计算语句,正确的选项是?

在升序数组 nums 中寻找目标值 target,给定如下Python二分查找代码,补全其中空缺的语句:

class Search(object):
    def search(self, nums, target):
        left, right = 0, len(nums) - 1
        while left <= right:
            _________________
            if nums[mid] == target:
                return mid
            elif nums[mid] > target:
                right = mid - 1
            else:
                left = mid + 1
        return -1
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析