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
+35 -37
View File
@@ -494,12 +494,11 @@
# 通过索引遍历列表
count = 0
for i in range(len(nums)):
count += 1
count += nums[i]
# 直接遍历列表元素
count = 0
for num in nums:
count += 1
count += num
```
=== "C++"
@@ -508,13 +507,13 @@
/* 通过索引遍历列表 */
int count = 0;
for (int i = 0; i < nums.size(); i++) {
count++;
count += nums[i];
}
/* 直接遍历列表元素 */
count = 0;
for (int num : nums) {
count++;
count += num;
}
```
@@ -524,13 +523,12 @@
/* 通过索引遍历列表 */
int count = 0;
for (int i = 0; i < nums.size(); i++) {
count++;
count += nums.get(i);
}
/* 直接遍历列表元素 */
count = 0;
for (int num : nums) {
count++;
count += num;
}
```
@@ -540,13 +538,13 @@
/* 通过索引遍历列表 */
int count = 0;
for (int i = 0; i < nums.Count; i++) {
count++;
count += nums[i];
}
/* 直接遍历列表元素 */
count = 0;
foreach (int num in nums) {
count++;
count += num;
}
```
@@ -556,13 +554,13 @@
/* 通过索引遍历列表 */
count := 0
for i := 0; i < len(nums); i++ {
count++
count += nums[i]
}
/* 直接遍历列表元素 */
count = 0
for range nums {
count++
for _, num := range nums {
count += num
}
```
@@ -571,14 +569,14 @@
```swift title="list.swift"
/* 通过索引遍历列表 */
var count = 0
for _ in nums.indices {
count += 1
for i in nums.indices {
count += nums[i]
}
/* 直接遍历列表元素 */
count = 0
for _ in nums {
count += 1
for num in nums {
count += num
}
```
@@ -588,13 +586,13 @@
/* 通过索引遍历列表 */
let count = 0;
for (let i = 0; i < nums.length; i++) {
count++;
count += nums[i];
}
/* 直接遍历列表元素 */
count = 0;
for (const num of nums) {
count++;
count += num;
}
```
@@ -604,13 +602,13 @@
/* 通过索引遍历列表 */
let count = 0;
for (let i = 0; i < nums.length; i++) {
count++;
count += nums[i];
}
/* 直接遍历列表元素 */
count = 0;
for (const num of nums) {
count++;
count += num;
}
```
@@ -619,30 +617,30 @@
```dart title="list.dart"
/* 通过索引遍历列表 */
int count = 0;
for (int i = 0; i < nums.length; i++) {
count++;
for (var i = 0; i < nums.length; i++) {
count += nums[i];
}
/* 直接遍历列表元素 */
count = 0;
for (int num in nums) {
count++;
for (var num in nums) {
count += num;
}
```
=== "Rust"
```rust title="list.rs"
/* 通过索引遍历列表 */
let mut count = 0;
for (index, value) in nums.iter().enumerate() {
count += 1;
// 通过索引遍历列表
let mut _count = 0;
for i in 0..nums.len() {
_count += nums[i];
}
/* 直接遍历列表元素 */
let mut count = 0;
for value in nums.iter() {
count += 1;
// 直接遍历列表元素
_count = 0;
for num in &nums {
_count += num;
}
```
@@ -659,13 +657,13 @@
var count: i32 = 0;
var i: i32 = 0;
while (i < nums.items.len) : (i += 1) {
count += 1;
count += nums[i];
}
// 直接遍历列表元素
count = 0;
for (nums.items) |_| {
count += 1;
for (nums.items) |num| {
count += num;
}
```