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

Method insert_word

strings/autocomplete_using_trie.py:10–16  ·  view source on GitHub ↗
(self, text: str)

Source from the content-addressed store, hash-verified

8 self._trie: dict = {}
9
10 def insert_word(self, text: str) -> None:
11 trie = self._trie
12 for char in text:
13 if char not in trie:
14 trie[char] = {}
15 trie = trie[char]
16 trie[END] = True
17
18 def find_word(self, prefix: str) -> tuple | list:
19 trie = self._trie

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected