Several bug fixes and improvements (#945)

* Update Dockerfile for code debugging.

* Format Python code using Black.

* Improve dark theme by defining html classes for the figures, animations and cover images.

* Fix several glossary translation.

* Update a code comment.

* Fix climbing_stairs_backtrack: the pruning should not require the sorted choices list.

* Update the code of array and list traversal.

* Fix a rendering issue of README.md

* Update code of list traversal.

* Fix array_definition.png

* Update README.md

* Fix max_capacity_moving_short_board.png

* Fix array.dart

* Fix array.dart

* Fix array.dart

* Fix array.dart
This commit is contained in:
Yudong Jin
2023-11-14 21:27:35 +08:00
committed by GitHub
parent 9baf4a1753
commit fcbaf101a4
64 changed files with 212 additions and 218 deletions

View File

@ -50,13 +50,14 @@ def traverse(nums: list[int]):
count = 0
# 通过索引遍历数组
for i in range(len(nums)):
count += 1
# 直接遍历数组
count += nums[i]
# 直接遍历数组元素
for num in nums:
count += 1
count += num
# 同时遍历数据索引和元素
for i, num in enumerate(nums):
count += 1
count += nums[i]
count += num
def find(nums: list[int], target: int) -> int:

View File

@ -38,16 +38,13 @@ if __name__ == "__main__":
nums.pop(3)
print("\n删除索引 3 处的元素,得到 nums =", nums)
# 遍历列表
tmp = []
# 通过索引遍历列表
count = 0
for i in range(len(nums)):
tmp.append(nums[i])
print(f"\n通过索引遍历列表得到 tmp = {tmp}")
tmp.clear()
count += nums[i]
# 直接遍历列表元素
for num in nums:
tmp.append(num)
print(f"\n直接遍历列表元素得到 tmp = {tmp}")
count += num
# 拼接两个列表
nums1 = [6, 8, 7, 10, 9]