From 431a0f6caf03f9f650dc8ab3159c21fce3da4cfd Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Sun, 27 Nov 2022 04:19:16 +0800 Subject: [PATCH] 1. Add C++ codes for the chapter of computational complexity, sorting, searching. 2. Corrected some mistakes. 3. Update README. --- README.md | 4 +- codes/cpp/.gitignore | 8 +++ .../chapter_array_and_linkedlist/array.cpp | 2 + .../linked_list.cpp | 2 + .../cpp/chapter_array_and_linkedlist/list.cpp | 2 + .../chapter_array_and_linkedlist/my_list.cpp | 2 + .../leetcode_two_sum.cpp | 47 +++++++++++++++++ .../space_complexity_types.cpp | 2 + .../time_complexity_types.cpp | 2 + .../worst_best_time_complexity.cpp | 2 + codes/cpp/chapter_searching/binary_search.cpp | 2 + .../cpp/chapter_searching/hashing_search.cpp | 2 + codes/cpp/chapter_searching/linear_search.cpp | 2 + codes/cpp/chapter_sorting/bubble_sort.cpp | 2 + codes/cpp/chapter_sorting/insertion_sort.cpp | 2 + codes/cpp/chapter_sorting/merge_sort.cpp | 2 + codes/cpp/chapter_sorting/quick_sort.cpp | 2 + .../chapter_stack_and_queue/array_queue.cpp | 2 + .../chapter_stack_and_queue/array_stack.cpp | 2 + codes/cpp/chapter_stack_and_queue/deque.cpp | 2 + .../linkedlist_queue.cpp | 2 + .../linkedlist_stack.cpp | 2 + codes/cpp/chapter_stack_and_queue/queue.cpp | 2 + codes/cpp/chapter_stack_and_queue/stack.cpp | 2 + codes/cpp/chapter_tree/binary_search_tree.cpp | 2 + codes/cpp/chapter_tree/binary_tree.cpp | 2 + codes/cpp/chapter_tree/binary_tree_bfs.cpp | 2 + codes/cpp/chapter_tree/binary_tree_dfs.cpp | 2 + .../leetcode_two_sum_test.go | 5 +- .../chapter_searching/linear_search_test.go | 7 +-- .../chapter_tree/binary_search_tree_test.go | 16 +++--- codes/go/chapter_tree/binary_tree_bfs_test.go | 5 +- codes/go/chapter_tree/binary_tree_dfs_test.go | 9 ++-- .../leetcode_two_sum.java | 4 +- .../leetcode_two_sum.py | 4 +- docs/chapter_preface/contribution.md | 30 +++++------ docs/leetcode.md | 52 ------------------- 37 files changed, 147 insertions(+), 94 deletions(-) create mode 100644 codes/cpp/.gitignore delete mode 100644 docs/leetcode.md diff --git a/README.md b/README.md index 1a2c886..98ce4ca 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ 本书定期更新中,希望您可以一同参与到本书的创作中来,详情见 [一起参与创作](https://www.hello-algo.com/chapter_preface/contribution/) 。 - 如果发现笔误、无效链接、内容缺失、文字歧义、解释不清晰、行文结构不合理等问题,烦请您帮忙修正内容,以帮助其他读者获取更优质的学习内容。 -- 非常欢迎您和我一同来创作本书,包括重写某章节、新增章节等,如果有意请与我联系 WeChat: krahets-jyd , Email: krahets@163.com 。 +- 非常欢迎您和我一同来创作本书,包括重写章节、新增章节、翻译代码至不同语言等,如果有意请与我联系 WeChat: krahets-jyd , Email: krahets@163.com 。 如果感觉本书对你有所帮助,请点个 Star 支持一下,谢谢! @@ -48,7 +48,7 @@ ## To-Dos -- [x] [代码翻译](https://github.com/krahets/hello-algo/issues/15)(JavaScript, TypeScript, C, C#, ... 请求大佬帮助) +- [x] [代码翻译](https://github.com/krahets/hello-algo/issues/15)(JavaScript, TypeScript, C, C++, C#, ... 寻求大佬帮助) - [ ] 数据结构:散列表、堆(优先队列)、图 - [ ] 算法:搜索与回溯、选择 / 堆排序、动态规划、贪心、分治 diff --git a/codes/cpp/.gitignore b/codes/cpp/.gitignore new file mode 100644 index 0000000..08b67f3 --- /dev/null +++ b/codes/cpp/.gitignore @@ -0,0 +1,8 @@ +# Ignore all +* +# Unignore all with extensions +!*.* +# Unignore all dirs +!*/ + +*.dSYM/ \ No newline at end of file diff --git a/codes/cpp/chapter_array_and_linkedlist/array.cpp b/codes/cpp/chapter_array_and_linkedlist/array.cpp index d52e9d9..422bcc4 100644 --- a/codes/cpp/chapter_array_and_linkedlist/array.cpp +++ b/codes/cpp/chapter_array_and_linkedlist/array.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp b/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp index 0ef70fc..092045b 100644 --- a/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp +++ b/codes/cpp/chapter_array_and_linkedlist/linked_list.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_array_and_linkedlist/list.cpp b/codes/cpp/chapter_array_and_linkedlist/list.cpp index 08b72d5..06e2818 100644 --- a/codes/cpp/chapter_array_and_linkedlist/list.cpp +++ b/codes/cpp/chapter_array_and_linkedlist/list.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_array_and_linkedlist/my_list.cpp b/codes/cpp/chapter_array_and_linkedlist/my_list.cpp index 66d4078..6b24eed 100644 --- a/codes/cpp/chapter_array_and_linkedlist/my_list.cpp +++ b/codes/cpp/chapter_array_and_linkedlist/my_list.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_computational_complexity/leetcode_two_sum.cpp b/codes/cpp/chapter_computational_complexity/leetcode_two_sum.cpp index c8f1003..24bb181 100644 --- a/codes/cpp/chapter_computational_complexity/leetcode_two_sum.cpp +++ b/codes/cpp/chapter_computational_complexity/leetcode_two_sum.cpp @@ -4,3 +4,50 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + +class SolutionBruteForce { +public: + vector twoSum(vector& nums, int target) { + int size = nums.size(); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + if (nums[i] + nums[j] == target) + return { i, j }; + } + } + return {}; + } +}; + +class SolutionHashMap { +public: + vector twoSum(vector& nums, int target) { + int size = nums.size(); + unordered_map dic; + for (int i = 0; i < size; i++) { + if (dic.find(target - nums[i]) != dic.end()) { + return { dic[target - nums[i]], i }; + } + dic.emplace(nums[i], i); + } + return {}; + } +}; + + +int main() { + // ======= Test Case ======= + vector nums = { 2,7,11,15 }; + int target = 9; + + // ====== Driver Code ====== + // 方法一 + SolutionBruteForce* slt1 = new SolutionBruteForce(); + vector res = slt1->twoSum(nums, target); + PrintUtil::printVector(res); + // 方法二 + SolutionHashMap* slt2 = new SolutionHashMap(); + res = slt2->twoSum(nums, target); + PrintUtil::printVector(res); +} diff --git a/codes/cpp/chapter_computational_complexity/space_complexity_types.cpp b/codes/cpp/chapter_computational_complexity/space_complexity_types.cpp index 78abdb7..0a7d765 100644 --- a/codes/cpp/chapter_computational_complexity/space_complexity_types.cpp +++ b/codes/cpp/chapter_computational_complexity/space_complexity_types.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_computational_complexity/time_complexity_types.cpp b/codes/cpp/chapter_computational_complexity/time_complexity_types.cpp index d913f77..dd4d4fa 100644 --- a/codes/cpp/chapter_computational_complexity/time_complexity_types.cpp +++ b/codes/cpp/chapter_computational_complexity/time_complexity_types.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp b/codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp index 9367e12..e6e7d8e 100644 --- a/codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp +++ b/codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_searching/binary_search.cpp b/codes/cpp/chapter_searching/binary_search.cpp index 7ce1040..5bd3a94 100644 --- a/codes/cpp/chapter_searching/binary_search.cpp +++ b/codes/cpp/chapter_searching/binary_search.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_searching/hashing_search.cpp b/codes/cpp/chapter_searching/hashing_search.cpp index 8c2eafb..df2b136 100644 --- a/codes/cpp/chapter_searching/hashing_search.cpp +++ b/codes/cpp/chapter_searching/hashing_search.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_searching/linear_search.cpp b/codes/cpp/chapter_searching/linear_search.cpp index 451a13f..1243d90 100644 --- a/codes/cpp/chapter_searching/linear_search.cpp +++ b/codes/cpp/chapter_searching/linear_search.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_sorting/bubble_sort.cpp b/codes/cpp/chapter_sorting/bubble_sort.cpp index 3afc020..9949dba 100644 --- a/codes/cpp/chapter_sorting/bubble_sort.cpp +++ b/codes/cpp/chapter_sorting/bubble_sort.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_sorting/insertion_sort.cpp b/codes/cpp/chapter_sorting/insertion_sort.cpp index bac8866..f3287ba 100644 --- a/codes/cpp/chapter_sorting/insertion_sort.cpp +++ b/codes/cpp/chapter_sorting/insertion_sort.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_sorting/merge_sort.cpp b/codes/cpp/chapter_sorting/merge_sort.cpp index 9120b38..0d4285d 100644 --- a/codes/cpp/chapter_sorting/merge_sort.cpp +++ b/codes/cpp/chapter_sorting/merge_sort.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_sorting/quick_sort.cpp b/codes/cpp/chapter_sorting/quick_sort.cpp index fb196ac..8c40804 100644 --- a/codes/cpp/chapter_sorting/quick_sort.cpp +++ b/codes/cpp/chapter_sorting/quick_sort.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/array_queue.cpp b/codes/cpp/chapter_stack_and_queue/array_queue.cpp index 6df107f..ac10cd5 100644 --- a/codes/cpp/chapter_stack_and_queue/array_queue.cpp +++ b/codes/cpp/chapter_stack_and_queue/array_queue.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/array_stack.cpp b/codes/cpp/chapter_stack_and_queue/array_stack.cpp index fda446f..e0112ed 100644 --- a/codes/cpp/chapter_stack_and_queue/array_stack.cpp +++ b/codes/cpp/chapter_stack_and_queue/array_stack.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/deque.cpp b/codes/cpp/chapter_stack_and_queue/deque.cpp index b48602e..cb777e8 100644 --- a/codes/cpp/chapter_stack_and_queue/deque.cpp +++ b/codes/cpp/chapter_stack_and_queue/deque.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/linkedlist_queue.cpp b/codes/cpp/chapter_stack_and_queue/linkedlist_queue.cpp index b8508cd..5c24229 100644 --- a/codes/cpp/chapter_stack_and_queue/linkedlist_queue.cpp +++ b/codes/cpp/chapter_stack_and_queue/linkedlist_queue.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/linkedlist_stack.cpp b/codes/cpp/chapter_stack_and_queue/linkedlist_stack.cpp index c3334b6..b4fba44 100644 --- a/codes/cpp/chapter_stack_and_queue/linkedlist_stack.cpp +++ b/codes/cpp/chapter_stack_and_queue/linkedlist_stack.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/queue.cpp b/codes/cpp/chapter_stack_and_queue/queue.cpp index 9f31c57..d76fca6 100644 --- a/codes/cpp/chapter_stack_and_queue/queue.cpp +++ b/codes/cpp/chapter_stack_and_queue/queue.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_stack_and_queue/stack.cpp b/codes/cpp/chapter_stack_and_queue/stack.cpp index 0504e7b..03cac3c 100644 --- a/codes/cpp/chapter_stack_and_queue/stack.cpp +++ b/codes/cpp/chapter_stack_and_queue/stack.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_tree/binary_search_tree.cpp b/codes/cpp/chapter_tree/binary_search_tree.cpp index 243b68f..601f89a 100644 --- a/codes/cpp/chapter_tree/binary_search_tree.cpp +++ b/codes/cpp/chapter_tree/binary_search_tree.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_tree/binary_tree.cpp b/codes/cpp/chapter_tree/binary_tree.cpp index f22a04b..8235cf9 100644 --- a/codes/cpp/chapter_tree/binary_tree.cpp +++ b/codes/cpp/chapter_tree/binary_tree.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_tree/binary_tree_bfs.cpp b/codes/cpp/chapter_tree/binary_tree_bfs.cpp index 5ecc7bd..9fd2faf 100644 --- a/codes/cpp/chapter_tree/binary_tree_bfs.cpp +++ b/codes/cpp/chapter_tree/binary_tree_bfs.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/cpp/chapter_tree/binary_tree_dfs.cpp b/codes/cpp/chapter_tree/binary_tree_dfs.cpp index 442de6e..e38c4ad 100644 --- a/codes/cpp/chapter_tree/binary_tree_dfs.cpp +++ b/codes/cpp/chapter_tree/binary_tree_dfs.cpp @@ -4,3 +4,5 @@ * Author: Krahets (krahets@163.com) */ +#include "../include/include.hpp" + diff --git a/codes/go/chapter_computational_complexity/leetcode_two_sum_test.go b/codes/go/chapter_computational_complexity/leetcode_two_sum_test.go index 9ddf9ea..b787c65 100644 --- a/codes/go/chapter_computational_complexity/leetcode_two_sum_test.go +++ b/codes/go/chapter_computational_complexity/leetcode_two_sum_test.go @@ -16,9 +16,8 @@ func TestTwoSum(t *testing.T) { // ====== Driver Code ====== // 方法一:暴力解法 res := twoSumBruteForce(nums, target) - t.Log("brute force:", res) - + t.Log("方法一 res =", res) // 方法二:哈希表 res = twoSumHashTable(nums, target) - t.Log("hash table:", res) + t.Log("方法二 res =", res) } diff --git a/codes/go/chapter_searching/linear_search_test.go b/codes/go/chapter_searching/linear_search_test.go index ffb800d..c240644 100644 --- a/codes/go/chapter_searching/linear_search_test.go +++ b/codes/go/chapter_searching/linear_search_test.go @@ -5,8 +5,9 @@ package chapter_searching import ( - . "github.com/krahets/hello-algo/pkg" "testing" + + . "github.com/krahets/hello-algo/pkg" ) func TestLinearSearch(t *testing.T) { @@ -15,10 +16,10 @@ func TestLinearSearch(t *testing.T) { // 在数组中执行线性查找 index := linerSearchArray(nums, target) - t.Log("目标元素 3 的索引 = ", index) + t.Log("目标元素 3 的索引 =", index) // 在链表中执行线性查找 head := ArrayToLinkedList(nums) node := linerSearchLinkedList(head, target) - t.Log("目标结点值 3 的对应结点对象为 ", node) + t.Log("目标结点值 3 的对应结点对象为", node) } diff --git a/codes/go/chapter_tree/binary_search_tree_test.go b/codes/go/chapter_tree/binary_search_tree_test.go index 955ebdb..5ae932b 100644 --- a/codes/go/chapter_tree/binary_search_tree_test.go +++ b/codes/go/chapter_tree/binary_search_tree_test.go @@ -9,33 +9,33 @@ import "testing" func TestBinarySearchTree(t *testing.T) { nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} bst := NewBinarySearchTree(nums) - t.Log("初始化的二叉树为: ") + t.Log("初始化的二叉树为:") bst.Print() // 获取根结点 node := bst.GetRoot() - t.Log("二叉树的根结点为: ", node.Val) + t.Log("二叉树的根结点为:", node.Val) // 获取最小的结点 node = bst.GetMin(bst.GetRoot()) - t.Log("二叉树的最小结点为: ", node.Val) + t.Log("二叉树的最小结点为:", node.Val) // 查找结点 node = bst.Search(5) - t.Log("查找到的结点对象为", node, ",结点值 = ", node.Val) + t.Log("查找到的结点对象为", node, ",结点值 =", node.Val) // 插入结点 node = bst.Insert(16) - t.Log("插入结点后 16 的二叉树为: ") + t.Log("插入结点后 16 的二叉树为:") bst.Print() // 删除结点 bst.Remove(1) - t.Log("删除结点 1 后的二叉树为: ") + t.Log("删除结点 1 后的二叉树为:") bst.Print() bst.Remove(2) - t.Log("删除结点 2 后的二叉树为: ") + t.Log("删除结点 2 后的二叉树为:") bst.Print() bst.Remove(4) - t.Log("删除结点 4 后的二叉树为: ") + t.Log("删除结点 4 后的二叉树为:") bst.Print() } diff --git a/codes/go/chapter_tree/binary_tree_bfs_test.go b/codes/go/chapter_tree/binary_tree_bfs_test.go index 48d3d38..c06cd9e 100644 --- a/codes/go/chapter_tree/binary_tree_bfs_test.go +++ b/codes/go/chapter_tree/binary_tree_bfs_test.go @@ -5,8 +5,9 @@ package chapter_tree import ( - . "github.com/krahets/hello-algo/pkg" "testing" + + . "github.com/krahets/hello-algo/pkg" ) func TestLevelOrder(t *testing.T) { @@ -18,5 +19,5 @@ func TestLevelOrder(t *testing.T) { // 层序遍历 nums := levelOrder(root) - t.Log("层序遍历的结点打印序列 = ", nums) + t.Log("层序遍历的结点打印序列 =", nums) } diff --git a/codes/go/chapter_tree/binary_tree_dfs_test.go b/codes/go/chapter_tree/binary_tree_dfs_test.go index 36ebb0b..2ee6295 100644 --- a/codes/go/chapter_tree/binary_tree_dfs_test.go +++ b/codes/go/chapter_tree/binary_tree_dfs_test.go @@ -5,8 +5,9 @@ package chapter_tree import ( - . "github.com/krahets/hello-algo/pkg" "testing" + + . "github.com/krahets/hello-algo/pkg" ) func TestPreInPostOrderTraversal(t *testing.T) { @@ -18,13 +19,13 @@ func TestPreInPostOrderTraversal(t *testing.T) { // 前序遍历 nums := preOrder(root) - t.Log("前序遍历的结点打印序列 = ", nums) + t.Log("前序遍历的结点打印序列 =", nums) // 中序遍历 nums = inOrder(root) - t.Log("中序遍历的结点打印序列 = ", nums) + t.Log("中序遍历的结点打印序列 =", nums) // 后序遍历 nums = postOrder(root) - t.Log("后序遍历的结点打印序列 = ", nums) + t.Log("后序遍历的结点打印序列 =", nums) } diff --git a/codes/java/chapter_computational_complexity/leetcode_two_sum.java b/codes/java/chapter_computational_complexity/leetcode_two_sum.java index a05c014..4510686 100644 --- a/codes/java/chapter_computational_complexity/leetcode_two_sum.java +++ b/codes/java/chapter_computational_complexity/leetcode_two_sum.java @@ -48,10 +48,10 @@ public class leetcode_two_sum { // 方法一 SolutionBruteForce slt1 = new SolutionBruteForce(); int[] res = slt1.twoSum(nums, target); - System.out.println(Arrays.toString(res)); + System.out.println("方法一 res = " + Arrays.toString(res)); // 方法二 SolutionHashMap slt2 = new SolutionHashMap(); res = slt2.twoSum(nums, target); - System.out.println(Arrays.toString(res)); + System.out.println("方法二 res = " + Arrays.toString(res)); } } diff --git a/codes/python/chapter_computational_complexity/leetcode_two_sum.py b/codes/python/chapter_computational_complexity/leetcode_two_sum.py index 61b7b5c..182caec 100644 --- a/codes/python/chapter_computational_complexity/leetcode_two_sum.py +++ b/codes/python/chapter_computational_complexity/leetcode_two_sum.py @@ -35,7 +35,7 @@ if __name__ == '__main__': # ====== Driver Code ====== # 方法一 res = SolutionBruteForce().twoSum(nums, target); - print(res) + print("方法一 res =", res) # 方法二 res = SolutionHashMap().twoSum(nums, target); - print(res) + print("方法二 res =", res) diff --git a/docs/chapter_preface/contribution.md b/docs/chapter_preface/contribution.md index 10c88d4..8bc8b29 100644 --- a/docs/chapter_preface/contribution.md +++ b/docs/chapter_preface/contribution.md @@ -8,9 +8,9 @@ comments: true 纸质书籍的两次印刷的间隔时间往往需要数年,内容更新非常不方便。
但在本开源 HTML 书中,内容更迭的时间被缩短至数日甚至几个小时。 -由于作者水平有限,书中内容难免疏漏谬误,请您谅解。此外,希望您可以一同参与到本书的内容创作中来。如果发现笔误、无效链接、内容缺失、文字歧义、解释不清晰、行文结构不合理等问题,烦请您修正内容,以帮助其他读者获取更优质的学习内容。 +由于作者水平有限,书中内容难免疏漏谬误,请您谅解。此外,期待您可以一同参与本书的创作。如果发现笔误、无效链接、内容缺失、文字歧义、解释不清晰、行文结构不合理等问题,烦请您修正内容,以帮助其他读者获取更优质的学习内容。所有 [撰稿人](https://github.com/krahets/hello-algo/graphs/contributors) 将被展示在仓库主页,以感谢您对开源社区的无私奉献。 -## 修改文字 +## 修改文字与代码 每个页面的右上角都有一个「编辑」按钮,你可以按照以下步骤修改文章: @@ -21,7 +21,7 @@ comments: true ![edit_markdown](contribution.assets/edit_markdown.png) -## 修改图片 +## 修改图片与动画 书中的配图无法直接修改,需要通过以下途径提出修改意见: @@ -29,18 +29,16 @@ comments: true 2. 描述图片问题,应如何修改; 3. 提交 Issue 即可,我会第一时间重新画图并替换图片。 -## 修改代码 - -若发现代码源文件有错误,可以本地修改并提交 Pull Request : - -1. 登录 GitHub ,并 Fork [本仓库](https://github.com/krahets/hello-algo) 至个人账号; -2. 使用 Git 克隆该 Fork 仓库至本地; -3. 在本地修改 `.java` , `.cpp` , `.py` 文件中的代码,并运行测试;测试完成后,请同步更新 Markdown 文章中的对应代码; -4. 将本地更新 Commit ,并 Push 至远程仓库; -5. 刷新仓库网页,点击 “Create pull request” 按钮发起拉取请求即可; - -(TODO:教学视频) - ## 创作新内容 -「修改代码」中介绍的是完整的 Pull Request 流程,还可以用来 **重写某章节、新增章节、翻译代码至其他编程语言** 等。非常欢迎您和我一同来创作本书! +如果您想要创作新内容,例如 **重写章节、新增章节、修改代码、翻译代码至其他编程语言** 等,那么需要实施 Pull Request 工作流程: + +1. 登录 GitHub ,并 Fork [本仓库](https://github.com/krahets/hello-algo) 至个人账号; +2. 进入 Fork 仓库网页,使用 `git clone` 克隆该仓库至本地; +3. 在本地进行内容创作(建议通过运行测试来验证代码正确性); +4. 将本地更改 Commit ,并 Push 至远程仓库; +5. 刷新仓库网页,点击 “Create pull request” 按钮发起拉取请求(Pull Request)即可; + +非常欢迎您和我一同来创作本书! + +(TODO:教学视频) diff --git a/docs/leetcode.md b/docs/leetcode.md deleted file mode 100644 index 2124492..0000000 --- a/docs/leetcode.md +++ /dev/null @@ -1,52 +0,0 @@ -Hello!我是「Krahets」,是一个分享了许多题解、编写了 LeetBook《图解算法数据结构》的扣友。 - -当年秋招时,我采用 “扫雷游戏” 式的学习方法,两眼一抹黑刷题,扫到不会的 “雷” 就通过查资料把它 “排掉” ,配合周期性总结,逐渐形成了数据结构与算法的知识图景。我虽然幸运地在秋招斩获了多家大厂的 Offer ,但回想自己当初在 “扫雷式” 刷题中被炸的满头包,很是痛苦。 - -开源性是互联网行业最吸引我的地方,只需要一台 PC ,我们可以学习到几乎所有所需知识。学习算法时,我阅读了许多大佬分享的文章,获益匪浅,一直以来我也想再为开源社区做点儿什么。思考良久,我意识到一本 “前期刷题必看” 的读物可以使算法小白少走许多弯路。写作意愿滚滚袭来,那就动笔吧! - -![hello-algo_1280_720.jpg](https://pic.leetcode.cn/1669284263-rbAMcs-hello-algo_1280_720.jpg){:width=500} - -前往仓库 > github.com/krahets/hello-algo -前往阅读 > https://www.hello-algo.com -{:style="text-align: center;"} - ---- - -## 「清晰动画讲解」 {:style="text-align: center;"} - -借助动画介绍重点,提升知识吸收效率 -支持笔记本、平板、手机全终端阅读 -{:style="text-align: center;"} - -![animation.gif](https://pic.leetcode.cn/1669280889-QVHgdw-animation.gif) - ---- - -## 「代码实践导向」 {:style="text-align: center;"} - -提供经典数据结构与算法的代码实现 -包含详细注释,皆可一键运行 -{:style="text-align: center;"} - -![running_code.gif](https://pic.leetcode.cn/1669280958-qiDPFd-running_code.gif) - ---- - -## 「可讨论与提问」 {:style="text-align: center;"} - -作者定期(一般 < 72h )回复评论问题 -在评论区与小伙伴们一起学习进步 -{:style="text-align: center;"} - -![comment.gif](https://pic.leetcode.cn/1669280943-aiwrOm-comment.gif) - ---- - -本书是我利用业余时间创作,完全开源免费,不会收取任何费用。 - -本书定期更新中,希望您可以一同参与到本书的创作中来,详情见 [一起参与创作](https://www.hello-algo.com/chapter_preface/contribution/) 。 - -- 如果发现笔误、无效链接、内容缺失、文字歧义、解释不清晰、行文结构不合理等问题,烦请您帮忙修正内容,以帮助其他读者获取更优质的学习内容。 -- 非常欢迎您和我一同来创作本书,包括重写某章节、新增章节、翻译代码至其他编程语言等,如果有意请与我联系或在楼下评论。 - -如果感觉本书对你有所帮助,请 [点个 Star](github.com/krahets/hello-algo) 支持一下,谢谢!