Tries to find word in a Trie :param word: word to look for :return: Returns True if word is found, False otherwise
(self, word: str)
| 35 | curr.is_leaf = True |
| 36 | |
| 37 | def find(self, word: str) -> bool: # noqa: E999 This syntax is Python 3 only |
| 38 | """ |
| 39 | Tries to find word in a Trie |
| 40 | :param word: word to look for |
| 41 | :return: Returns True if word is found, False otherwise |
| 42 | """ |
| 43 | curr = self |
| 44 | for char in word: |
| 45 | if char not in curr.nodes: |
| 46 | return False |
| 47 | curr = curr.nodes[char] |
| 48 | return curr.is_leaf |
| 49 | |
| 50 | |
| 51 | def print_words(node: TrieNode, word: str): # noqa: E999 This syntax is Python 3 only |
no outgoing calls
no test coverage detected