Polish the chapter

introduction, computational complexity.
This commit is contained in:
krahets
2023-08-20 14:51:39 +08:00
parent 5fb728b3d6
commit 2626de8d0b
87 changed files with 375 additions and 371 deletions

View File

@ -11,7 +11,7 @@ def binary_search(nums: list[int], target: int) -> int:
i, j = 0, len(nums) - 1
# 循环,当搜索区间为空时跳出(当 i > j 时为空)
while i <= j:
# 理论上 Python 的数字可以无限大(取决于内存大小),无考虑大数越界问题
# 理论上 Python 的数字可以无限大(取决于内存大小),无考虑大数越界问题
m = (i + j) // 2 # 计算中点索引 m
if nums[m] < target:
i = m + 1 # 此情况说明 target 在区间 [m+1, j] 中