diff --git a/README.md b/README.md index 459b49179..05371d136 100644 --- a/README.md +++ b/README.md @@ -180,9 +180,6 @@ leetcode 题解,记录自己的 leetcode 解题之路。 - [0094.binary-tree-inorder-traversal](./problems/94.binary-tree-inorder-traversal.md) - [0095.unique-binary-search-trees-ii](./problems/95.unique-binary-search-trees-ii.md) 🆕 - [0096.unique-binary-search-trees](./problems/96.unique-binary-search-trees.md) 🆕 - - 95.unique-binary-search-trees-ii - - [0098.validate-binary-search-tree](./problems/98.validate-binary-search-tree.md) - [0102.binary-tree-level-order-traversal](./problems/102.binary-tree-level-order-traversal.md) - [0103.binary-tree-zigzag-level-order-traversal](./problems/103.binary-tree-zigzag-level-order-traversal.md) diff --git a/problems/211.add-and-search-word-data-structure-design.md b/problems/211.add-and-search-word-data-structure-design.md index 69f7c2b8e..a11a1b332 100644 --- a/problems/211.add-and-search-word-data-structure-design.md +++ b/problems/211.add-and-search-word-data-structure-design.md @@ -36,6 +36,8 @@ search("b..") -> true 关于前缀树,LeetCode 有很多题目。有的是直接考察,让你实现一个前缀树,有的是间接考察,比如本题。前缀树代码见下方,大家之后可以直接当成前缀树的解题模板使用。 +![](https://tva1.sinaimg.cn/large/006tNbRwly1gb5dmstsxxj30mz0gqmzh.jpg) + 由于我们这道题需要考虑特殊字符".",因此我们需要对标准前缀树做一点改造,insert 不做改变,我们只需要改变 search 即可,代码(Python 3): ```python diff --git a/problems/212.word-search-ii.md b/problems/212.word-search-ii.md index 91af41761..951dfe639 100644 --- a/problems/212.word-search-ii.md +++ b/problems/212.word-search-ii.md @@ -35,8 +35,8 @@ words = ["oath","pea","eat","rain"] and board = 我们需要对矩阵中每一项都进行深度优先遍历(DFS)。 递归的终点是 -- 1. 超出边界 -- 2. 递归路径上组成的单词不在 words 的前缀。 +1. 超出边界 +2. 递归路径上组成的单词不在 words 的前缀。 比如题目示例:words = ["oath","pea","eat","rain"],那么对于 oa,oat 满足条件,因为他们都是 oath 的前缀,但是 oaa 就不满足条件。 @@ -44,6 +44,8 @@ words = ["oath","pea","eat","rain"] and board = 刚才我提到了一个关键词“前缀”,我们考虑使用前缀树来优化。使得复杂度降低为$O(h)$, 其中 h 是前缀树深度,也就是最长的字符串长度。 +![](https://tva1.sinaimg.cn/large/006tNbRwly1gb5dmstsxxj30mz0gqmzh.jpg) + ## 关键点 - 前缀树(也叫字典树),英文名 Trie(读作 tree 或者 try)