mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
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:
@ -50,11 +50,11 @@ function traverse(nums) {
|
||||
let count = 0;
|
||||
// 通过索引遍历数组
|
||||
for (let i = 0; i < nums.length; i++) {
|
||||
count++;
|
||||
count += nums[i];
|
||||
}
|
||||
// 直接遍历数组
|
||||
// 直接遍历数组元素
|
||||
for (const num of nums) {
|
||||
count += 1;
|
||||
count += num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -39,13 +39,12 @@ console.log(`删除索引 3 处的元素,得到 nums = ${nums}`);
|
||||
/* 通过索引遍历列表 */
|
||||
let count = 0;
|
||||
for (let i = 0; i < nums.length; i++) {
|
||||
count++;
|
||||
count += nums[i];
|
||||
}
|
||||
|
||||
/* 直接遍历列表元素 */
|
||||
count = 0;
|
||||
for (const n of nums) {
|
||||
count++;
|
||||
for (const x of nums) {
|
||||
count += x;
|
||||
}
|
||||
|
||||
/* 拼接两个列表 */
|
||||
|
||||
Reference in New Issue
Block a user