class Trie:
def __init__(self) -> None:
self.next = collections.defaultdict(Trie)
self.end = False
def add(self, word: str):
cur = self
for c in word:
cur = cur.next[c]
cur.end = True
字典树python模板
最新推荐文章于 2024-09-09 23:14:05 发布