Fixed format of doc
This commit is contained in:
parent
e0d3572a47
commit
88ce287a6f
@ -331,12 +331,12 @@ $$
|
||||
let i = 0, j = nums.length;
|
||||
// 循环,当搜索区间为空时跳出(当 i = j 时为空)
|
||||
while (i < j) {
|
||||
let m = Math.floor(i + (j - i) / 2); // 计算中点索引 m
|
||||
if (nums[m] < target) { // 此情况说明 target 在区间 [m+1, j) 中
|
||||
let m = Math.floor(i + (j - i) / 2);// 计算中点索引 m
|
||||
if (nums[m] < target) { // 此情况说明 target 在区间 [m+1, j) 中
|
||||
i = m + 1;
|
||||
} else if (nums[m] > target) { // 此情况说明 target 在区间 [i, m) 中
|
||||
} else if (nums[m] > target) { // 此情况说明 target 在区间 [i, m) 中
|
||||
j = m;
|
||||
} else { // 找到目标元素,返回其索引
|
||||
} else { // 找到目标元素,返回其索引
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user