Inserts a word into the Trie :param word: word to be inserted :return: None
(self, word: str)
| 21 | self.insert(word) |
| 22 | |
| 23 | def insert(self, word: str) -> None: |
| 24 | """ |
| 25 | Inserts a word into the Trie |
| 26 | :param word: word to be inserted |
| 27 | :return: None |
| 28 | """ |
| 29 | curr = self |
| 30 | for char in word: |
| 31 | if char not in curr.nodes: |
| 32 | curr.nodes[char] = TrieNode() |
| 33 | curr = curr.nodes[char] |
| 34 | curr.is_leaf = True |
| 35 | |
| 36 | def find(self, word: str) -> bool: |
| 37 | """ |