MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / find_word

Method find_word

strings/autocomplete_using_trie.py:18–25  ·  view source on GitHub ↗
(self, prefix: str)

Source from the content-addressed store, hash-verified

16 trie[END] = True
17
18 def find_word(self, prefix: str) -> tuple | list:
19 trie = self._trie
20 for char in prefix:
21 if char in trie:
22 trie = trie[char]
23 else:
24 return []
25 return self._elements(trie)
26
27 def _elements(self, d: dict) -> tuple:
28 result = []

Callers 1

autocomplete_using_trieFunction · 0.80

Calls 1

_elementsMethod · 0.95

Tested by

no test coverage detected