mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 18:00:18 +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:
@@ -51,12 +51,12 @@ pub fn traverse(nums: []i32) void {
|
||||
// 通过索引遍历数组
|
||||
var i: i32 = 0;
|
||||
while (i < nums.len) : (i += 1) {
|
||||
count += 1;
|
||||
count += nums[i];
|
||||
}
|
||||
count = 0;
|
||||
// 直接遍历数组
|
||||
for (nums) |_| {
|
||||
count += 1;
|
||||
// 直接遍历数组元素
|
||||
for (nums) |num| {
|
||||
count += num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,12 @@ pub fn main() !void {
|
||||
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) |x| {
|
||||
count += x;
|
||||
}
|
||||
|
||||
// 拼接两个列表
|
||||
|
||||
Reference in New Issue
Block a user