diff --git a/README.md b/README.md index 0b86fd601..75fb11166 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,41 @@ # 数据结构与算法 - Rust 语言实现 使用 Rust 语言实现所有的数据结构与算法. + +[在线浏览](https://algs.biofan.org), 或者[下载 pdf 文件](https://share.biofan.org/algs.pdf). + +本文档包括了以下几个部分的内容: +1. 第一部分: 数据结构 +2. 第二部分: 算法及其实现 +3. 第三部分: 专题 +4. 第四部分: leetcode 题解 + +## 反馈问题 + +欢迎 [反馈问题](https://github.com/xushaohua/TheAlgorithms/issues), 或者提交 PR. + +## 搭建本地环境 + +想在本地搭建本文档的环境也是很容易的. + +这些文档记录以 markdown 文件为主, 用 [mdbook](https://github.com/rust-lang/mdBook) 生成网页. + +用cargo来安装它: `cargo install mdbook mdbook-linkcheck` + +运行 `mdbook build` 命令, 会在`book/`目录里生成完整的电子书的网页版本. + +在编写文档的同时, mdbook 工具可以检查文件变更, 按需自动更新. +使用 `mdbook serve` 命令启动一个本地的 web 服务器, 在浏览器中打开 [http://localhost:3000](http://localhost:3000). + +### 生成 PDF + +如果想生成 pdf, 需要安装 [mdbook-pandoc](https://github.com/max-heller/mdbook-pandoc), +用命令: `cargo install mdbook-pandoc` + +并且安装 latex 相应的包: + +```bash +sudo apt install pandoc librsvg2-bin texlive-latex-recommended latex-cjk-all texlive-xetex +``` + +安装好依赖之后, 运行 `./tools/generate-pdf.sh` 命令, 就会生成 `book-pandoc/intro-to-rust.pdf`. diff --git a/src/SUMMARY.md b/src/SUMMARY.md index ae378c1b0..4526b891f 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -1,14 +1,14 @@ # 目录 -- [数据结构与算法 - Rust 语言实现](README.md) +[数据结构与算法 - Rust 语言实现](README.md) # 第一部分: 数据结构 Data Structures - [数组 Arrays](array/index.md) - - [数组相关的问题列表](leetcode/tags/array.md) - [前缀和数组 Prefix Sum Array](array/prefix-sum-array.md) - [前缀和相关的问题列表](leetcode/tags/prefix-sum.md) - [后缀数组 Suffix Array](array/suffix-array.md) + - [数组相关的问题列表](leetcode/tags/array.md) - [动态数组 Vector](vector/index.md) - [双端队列 Deque](deque/index.md) - [链表 List](list/index.md) @@ -34,11 +34,13 @@ - [二叉搜索树 Binary Search Tree](tree/binary-search-tree/index.md) - [AVL树](tree/avl-tree/index.md) - [红黑树 Red-Black Tree](tree/red-black-tree/index.md) + - [字典树 Trie](tree/trie/index.md) + - [多叉树](tree/multiway-tree/index.md) - [B-Tree](tree/btree/index.md) - [B+-Tree](tree/b+tree/index.md) - - [多叉树](tree/multiway-tree/index.md) - - [字典树 Trie](tree/trie/index.md) - [LSM-Tree](tree/lsm-tree/index.md) + - [Fractal-tree](tree/fractal-tree/index.md) + - [MergeTree](tree/merge-tree/index.md) - [树相关的问题列表](leetcode/tags/tree.md) - [图 Graph](graph/index.md) - [深度优先搜索 DFS](graph/dfs.md) @@ -92,10 +94,13 @@ - [贪心算法相关的问题列表](leetcode/tags/greedy.md) - [图算法 Graph](graph/index.md) -# 第三部分: 扩展主题 Extras +# 第三部分: 专题 Extras - [内存 Memory](memory/index.md) -- [leetcode 问题列表](leetcode/index.md) + +# 第四部分: leetcode 题解 + +- [leetcode 问题分类](leetcode/index.md) - [数组 Array](leetcode/tags/array.md) - [二分查找 Binary Search](leetcode/tags/binary-search.md) - [位运算 Bit Manipulation](leetcode/tags/bit-manipulation.md) @@ -115,7 +120,8 @@ - [字符串 String](leetcode/tags/string.md) - [双指针 Two Pointers](leetcode/tags/two-pointers.md) - [树 Tree](leetcode/tags/tree.md) - - [0001-0100](leetcode/orders/0001-0100.md) +- [leetcode 题解](leetcode/index.md) + - [0001-0100](leetcode/by-id/0001-0100.md) - [0001. 两数之和 Two Sum](leetcode/0001.two-sum/index.md) - [0007. 整数反转 Reverse Integer](leetcode/0007.reverse-integer/index.md) - [0011. 盛最多水的容器 Container With Most Water](leetcode/0011.container-with-most-water/index.md) @@ -137,50 +143,51 @@ - [0083. 删除排序链表中的重复元素 Remove Duplicates from Sorted List](leetcode/0083.remove-duplicates-from-sorted-list/index.md) - [0088. 合并两个有序数组 Merge Sorted Array](leetcode/0088.merge-sorted-array/index.md) - [0090. 子集 II Subsets II](leetcode/0090.subsets-ii/index.md) - - [0101-0200](leetcode/orders/0101-0200.md) + - [0101-0200](leetcode/by-id/0101-0200.md) - [0125. 验证回文串 Valid Palindrome](leetcode/0125.valid-palindrome/index.md) - [0136. 只出现一次的数字 Single Number](leetcode/0136.single-number/index.md) - [0137. 只出现一次的数字II Single Number II](leetcode/0137.single-number-ii/index.md) - [0167. 两数之和 II - 输入有序数组 Two Sum II - Input Array Is Sorted](leetcode/0167.two-sum-ii-input-array-is-sorted/index.md) - [0191. 位1的个数 Number of 1 Bits](leetcode/0191.number-of-1-bits/index.md) - - [0201-0300](leetcode/orders/0201-0300.md) + - [0201-0300](leetcode/by-id/0201-0300.md) - [0217. 存在重复元素 Contains Duplicate](leetcode/0217.contains-duplicate/index.md) - [0219. 存在重复元素II Contains Duplicate II](leetcode/0219.contains-duplicate-ii/index.md) - [0231. 2的幂 Power of Two](leetcode/0231.power-of-two/index.md) - [0234. 回文链表 Palindrome Linked List](leetcode/0234.palindrome-linked-list/index.md) - - [0301-0400](leetcode/orders/0301-0400.md) + - [0301-0400](leetcode/by-id/0301-0400.md) - [0326. 3的幂 Power of Three](leetcode/0326.power-of-three/index.md) - [0338. 比特位计数 Counting Bits](leetcode/0338.counting-bits/index.md) - [0342. 4的幂 Power of Four](leetcode/0342.power-of-four/index.md) - [0349. 两个数组的交集 Intersection of Two Arrays](leetcode/0349.intersection-of-two-arrays/index.md) - [0350. 两个数组的交集 II Intersection of Two Arrays II](leetcode/0350.intersection-of-two-arrays-ii/index.md) - - [0401-0500](leetcode/orders/0401-0500.md) + - [0401-0500](leetcode/by-id/0401-0500.md) - [0485. 最大连续1的个数 Max Consecutive Ones](leetcode/0485.max-consecutive-ones/index.md) - - [0501-0600](leetcode/orders/0501-0600.md) + - [0501-0600](leetcode/by-id/0501-0600.md) - [0532.数组中的数对 K-diff Pairs in an Array](leetcode/0532.k-diff-pairs-in-an-array/index.md) - - [0601-0700](leetcode/orders/0601-0700.md) + - [0601-0700](leetcode/by-id/0601-0700.md) - [0679. 24 点游戏 24 Game](leetcode/0679.24-game/index.md) - [0680. 验证回文串 II Valid Palindrome II](leetcode/0680.valid-palindrome-ii/index.md) - - [0701-0800](leetcode/orders/0701-0800.md) + - [0701-0800](leetcode/by-id/0701-0800.md) - [0707. 设计链表 Design Linked List](leetcode/0707.design-linked-list/index.md) - - [0801-0900](leetcode/orders/0801-0900.md) - - [0901-1000](leetcode/orders/0901-1000.md) + - [0801-0900](leetcode/by-id/0801-0900.md) + - [0901-1000](leetcode/by-id/0901-1000.md) - [0925. 长按键入 Long Pressed Name](leetcode/0925.long-pressed-name/index.md) - [0977. 有序数组的平方 Squares of a Sorted Array](leetcode/0977.squares-of-a-sorted-array/index.md) - - [1001-1100](leetcode/orders/1001-1100.md) - - [1101-1200](leetcode/orders/1101-1200.md) - - [1201-1300](leetcode/orders/1201-1300.md) - - [1301-1400](leetcode/orders/1301-1400.md) - - [1401-1500](leetcode/orders/1401-1500.md) + - [1001-1100](leetcode/by-id/1001-1100.md) + - [1101-1200](leetcode/by-id/1101-1200.md) + - [1201-1300](leetcode/by-id/1201-1300.md) + - [1301-1400](leetcode/by-id/1301-1400.md) + - [1401-1500](leetcode/by-id/1401-1500.md) - [1498. 满足条件的子序列数目 Number of Subsequences That Satisfy the Given Sum Condition](leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition/index.md) - - [1501-1600](leetcode/orders/1501-1600.md) + - [1501-1600](leetcode/by-id/1501-1600.md) - [1518. 换水问题 Water Bottles](leetcode/1518.water-bottles/index.md) - - [1601-1700](leetcode/orders/1601-1700.md) - - [1701-1800](leetcode/orders/1701-1800.md) + - [1601-1700](leetcode/by-id/1601-1700.md) + - [1701-1800](leetcode/by-id/1701-1800.md) - [1780. 判断一个数字是否可以表示成三的幂的和 Check if Number is a Sum of Powers of Three](leetcode/1780.check-if-number-is-a-sum-of-powers-of-three/index.md) - - [1801-1900](leetcode/orders/1801-1900.md) - - [1901-2000](leetcode/orders/1901-2000.md) - - [2101-2200](leetcode/orders/2101-2200.md) + - [1801-1900](leetcode/by-id/1801-1900.md) + - [1901-2000](leetcode/by-id/1901-2000.md) + - [2101-2200](leetcode/by-id/2101-2200.md) - [2108. 找出数组中的第一个回文字符串 Find First Palindromic String in the Array](leetcode/2108.find-first-palindromic-string-in-the-array/index.md) - [2119. 反转两次的数字 A Number After a Double Reversal](leetcode/2119.a-number-after-a-double-reversal/index.md) -- [参考资料](refs.md) + +[参考资料](refs.md) diff --git a/src/leetcode/orders/0001-0100.md b/src/leetcode/by-id/0001-0100.md similarity index 100% rename from src/leetcode/orders/0001-0100.md rename to src/leetcode/by-id/0001-0100.md diff --git a/src/leetcode/orders/0101-0200.md b/src/leetcode/by-id/0101-0200.md similarity index 100% rename from src/leetcode/orders/0101-0200.md rename to src/leetcode/by-id/0101-0200.md diff --git a/src/leetcode/orders/0201-0300.md b/src/leetcode/by-id/0201-0300.md similarity index 100% rename from src/leetcode/orders/0201-0300.md rename to src/leetcode/by-id/0201-0300.md diff --git a/src/leetcode/orders/0301-0400.md b/src/leetcode/by-id/0301-0400.md similarity index 100% rename from src/leetcode/orders/0301-0400.md rename to src/leetcode/by-id/0301-0400.md diff --git a/src/leetcode/orders/0401-0500.md b/src/leetcode/by-id/0401-0500.md similarity index 100% rename from src/leetcode/orders/0401-0500.md rename to src/leetcode/by-id/0401-0500.md diff --git a/src/leetcode/orders/0501-0600.md b/src/leetcode/by-id/0501-0600.md similarity index 100% rename from src/leetcode/orders/0501-0600.md rename to src/leetcode/by-id/0501-0600.md diff --git a/src/leetcode/orders/0601-0700.md b/src/leetcode/by-id/0601-0700.md similarity index 100% rename from src/leetcode/orders/0601-0700.md rename to src/leetcode/by-id/0601-0700.md diff --git a/src/leetcode/orders/0701-0800.md b/src/leetcode/by-id/0701-0800.md similarity index 100% rename from src/leetcode/orders/0701-0800.md rename to src/leetcode/by-id/0701-0800.md diff --git a/src/leetcode/orders/0801-0900.md b/src/leetcode/by-id/0801-0900.md similarity index 100% rename from src/leetcode/orders/0801-0900.md rename to src/leetcode/by-id/0801-0900.md diff --git a/src/leetcode/orders/0901-1000.md b/src/leetcode/by-id/0901-1000.md similarity index 100% rename from src/leetcode/orders/0901-1000.md rename to src/leetcode/by-id/0901-1000.md diff --git a/src/leetcode/orders/1001-1100.md b/src/leetcode/by-id/1001-1100.md similarity index 100% rename from src/leetcode/orders/1001-1100.md rename to src/leetcode/by-id/1001-1100.md diff --git a/src/leetcode/orders/1101-1200.md b/src/leetcode/by-id/1101-1200.md similarity index 100% rename from src/leetcode/orders/1101-1200.md rename to src/leetcode/by-id/1101-1200.md diff --git a/src/leetcode/orders/1201-1300.md b/src/leetcode/by-id/1201-1300.md similarity index 100% rename from src/leetcode/orders/1201-1300.md rename to src/leetcode/by-id/1201-1300.md diff --git a/src/leetcode/orders/1301-1400.md b/src/leetcode/by-id/1301-1400.md similarity index 100% rename from src/leetcode/orders/1301-1400.md rename to src/leetcode/by-id/1301-1400.md diff --git a/src/leetcode/orders/1401-1500.md b/src/leetcode/by-id/1401-1500.md similarity index 100% rename from src/leetcode/orders/1401-1500.md rename to src/leetcode/by-id/1401-1500.md diff --git a/src/leetcode/orders/1501-1600.md b/src/leetcode/by-id/1501-1600.md similarity index 100% rename from src/leetcode/orders/1501-1600.md rename to src/leetcode/by-id/1501-1600.md diff --git a/src/leetcode/orders/1601-1700.md b/src/leetcode/by-id/1601-1700.md similarity index 100% rename from src/leetcode/orders/1601-1700.md rename to src/leetcode/by-id/1601-1700.md diff --git a/src/leetcode/orders/1701-1800.md b/src/leetcode/by-id/1701-1800.md similarity index 100% rename from src/leetcode/orders/1701-1800.md rename to src/leetcode/by-id/1701-1800.md diff --git a/src/leetcode/orders/1801-1900.md b/src/leetcode/by-id/1801-1900.md similarity index 100% rename from src/leetcode/orders/1801-1900.md rename to src/leetcode/by-id/1801-1900.md diff --git a/src/leetcode/orders/1901-2000.md b/src/leetcode/by-id/1901-2000.md similarity index 100% rename from src/leetcode/orders/1901-2000.md rename to src/leetcode/by-id/1901-2000.md diff --git a/src/leetcode/orders/2101-2200.md b/src/leetcode/by-id/2101-2200.md similarity index 100% rename from src/leetcode/orders/2101-2200.md rename to src/leetcode/by-id/2101-2200.md diff --git a/src/leetcode/index.md b/src/leetcode/index.md index a0245636e..69f647dd0 100644 --- a/src/leetcode/index.md +++ b/src/leetcode/index.md @@ -1,4 +1,4 @@ -# leetcode 问题列表 +# leetcode 问题分类 这一章节, 分别基于问题所属的标签, 和问题编号, 列出问题, 方便索引. diff --git a/src/tree/fractal-tree/index.md b/src/tree/fractal-tree/index.md new file mode 100644 index 000000000..c34d7aa8f --- /dev/null +++ b/src/tree/fractal-tree/index.md @@ -0,0 +1 @@ +# Fractal-tree \ No newline at end of file diff --git a/src/tree/merge-tree/index.md b/src/tree/merge-tree/index.md new file mode 100644 index 000000000..7bb85014d --- /dev/null +++ b/src/tree/merge-tree/index.md @@ -0,0 +1 @@ +# MergeTree \ No newline at end of file