mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-05 04:04:22 +00: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:
@@ -52,12 +52,17 @@ func traverse(nums []int) {
|
||||
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
|
||||
}
|
||||
// 同时遍历数据索引和元素
|
||||
for i, num := range nums {
|
||||
count += nums[i]
|
||||
count += num
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user