题目
python写法
利用isword标识到当前位置是否是一个单词的结束
class TrieNode:
def __init__(self):
self.isword = False
self.childs = {
}
class Trie:
def __init__(self):
self.root = TrieNode()
def insert(self, word: str) -> None:
root = self.root
for c in word:
if c not in root.childs:
root.childs[c] = TrieNode()
root = root.childs[c]
root.isword = True
def