Skip to content

Commit

Permalink
Create Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Sep 25, 2017
1 parent cf8b395 commit acfe6bc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Trie/676.Implement-Magic-Dictionary/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### 676.Implement-Magic-Dictionary

此题特征就是用Trie树,实现高效的单词搜索。Trie树的一些基本操作应数量掌握,包括构建树 buildTree(string word, TrieNode* node),搜索一个单词是否在此字典树内 inDictionary(string word, TrieNode* node).

对于单词abcdefg,先考虑置换第一个字母a,换成其他字母后,考察bcdefg是否是在这个字典树node内,需要调用inDictionary。如果从a到z的置换都不成功,则将根节点下降一层node=node->next['a'-'a'],同时word=word.substr(1),就将问题转化为在新的字典树node理考察word(bcdefg),这样可以递归调用整个search的过程。

0 comments on commit acfe6bc

Please sign in to comment.