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