diff --git a/docs/chapter_backtracking/backtracking_algorithm.md b/docs/chapter_backtracking/backtracking_algorithm.md index 1466c5370..04e9d672a 100644 --- a/docs/chapter_backtracking/backtracking_algorithm.md +++ b/docs/chapter_backtracking/backtracking_algorithm.md @@ -317,7 +317,7 @@ comments: true *path = append(*path, root) if root.Val.(int) == 7 { // 记录解 - *res = append(*res, *path) + *res = append(*res, append([]*TreeNode{}, *path...)) } preOrderII(root.Left, res, path) preOrderII(root.Right, res, path) diff --git a/docs/chapter_hashing/hash_collision.md b/docs/chapter_hashing/hash_collision.md index a227bb496..5ea302570 100644 --- a/docs/chapter_hashing/hash_collision.md +++ b/docs/chapter_hashing/hash_collision.md @@ -498,7 +498,7 @@ comments: true /* 负载因子 */ func (m *hashMapChaining) loadFactor() float64 { - return float64(m.size / m.capacity) + return float64(m.size) / float64(m.capacity) } /* 查询操作 */ @@ -523,9 +523,9 @@ comments: true } idx := m.hashFunc(key) // 遍历桶,若遇到指定 key ,则更新对应 val 并返回 - for _, p := range m.buckets[idx] { - if p.key == key { - p.val = val + for i := range m.buckets[idx] { + if m.buckets[idx][i].key == key { + m.buckets[idx][i].val = val return } } @@ -1931,6 +1931,7 @@ comments: true // 若遇到指定 key ,则更新对应 val if m.buckets[j].key == key { m.buckets[j].val = val + return } } } diff --git a/docs/chapter_preface/about_the_book.md b/docs/chapter_preface/about_the_book.md index 1fbc3d5a0..b1f3b2b25 100644 --- a/docs/chapter_preface/about_the_book.md +++ b/docs/chapter_preface/about_the_book.md @@ -49,4 +49,4 @@ comments: true 本书倡导手脑并用的学习方式,在这一点上深受[《动手学深度学习》](https://github.com/d2l-ai/d2l-zh)的启发。在此向各位读者强烈推荐这本优秀的著作。 -衷心感谢我的父母,正是你们一直以来的支持与鼓励,让我有机会做这件富有趣味的事。 +**衷心感谢我的父母,正是你们一直以来的支持与鼓励,让我有机会做这件富有趣味的事**。 diff --git a/docs/chapter_sorting/bubble_sort.md b/docs/chapter_sorting/bubble_sort.md index a4e1c627b..68d08b4d5 100755 --- a/docs/chapter_sorting/bubble_sort.md +++ b/docs/chapter_sorting/bubble_sort.md @@ -244,7 +244,7 @@ comments: true // 外循环:未排序区间为 [0, i] for (int i = size - 1; i > 0; i--) { // 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端 - for (int j = 0; j < size - 1 - i; j++) { + for (int j = 0; j < i; j++) { if (nums[j] > nums[j + 1]) { int temp = nums[j]; nums[j] = nums[j + 1]; @@ -518,7 +518,7 @@ comments: true for (int i = size - 1; i > 0; i--) { bool flag = false; // 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端 - for (int j = 0; j < size - 1 - i; j++) { + for (int j = 0; j < i; j++) { if (nums[j] > nums[j + 1]) { int temp = nums[j]; nums[j] = nums[j + 1];