def__init__(self): self.root = TrieNode() definsert(self, word: str) -> None: current = self.root for char in word: if char notin current.children: current.children[char] = TrieNode() current = current.children[char] current.is_end = True defsearch(self, word: str) -> bool: current = self.root for char in word: if char notin current.children: returnFalse current = current.children[char] return current.is_end defstartsWith(self, prefix: str) -> bool: current = self.root for char in prefix: if char notin current.children: returnFalse current = current.children[char] returnTrue # Your Trie object will be instantiated and called as such: # obj = Trie() # obj.insert(word) # param_2 = obj.search(word) # param_3 = obj.startsWith(prefix)