This commit is contained in:
krahets
2023-08-30 15:28:46 +08:00
parent ca49da47f0
commit 5f4a7728b2
9 changed files with 877 additions and 58 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ comments: true
接下来,循环执行以下两步。
1. 计算中点索引 $m = \lfloor {(i + j) / 2} \rfloor$ ,其中 $\lfloor \space \rfloor$ 表示向下取整操作。
1. 计算中点索引 $m = \lfloor {(i + j) / 2} \rfloor$ ,其中 $\lfloor \: \rfloor$ 表示向下取整操作。
2. 判断 `nums[m]``target` 的大小关系,分为以下三种情况。
1.`nums[m] < target` 时,说明 `target` 在区间 $[m + 1, j]$ 中,因此执行 $i = m + 1$ 。
2.`nums[m] > target` 时,说明 `target` 在区间 $[i, m - 1]$ 中,因此执行 $j = m - 1$ 。