You are viewing a single comment's thread. Return to all comments →
trie with python:
class TrieNode: def __init__(self): self.children = {} self.is_end_of_word = False def insert_word(root, word): current = root for char in word: if char not in current.children: current.children[char] = TrieNode() current = current.children[char] if current.is_end_of_word: return False current.is_end_of_word = True if len(current.children) > 0: return False return True def noPrefix(words): # Write your code here root = TrieNode() for word in words: if not insert_word(root, word): print("BAD SET") print(word) return print("GOOD SET")
Seems like cookies are disabled on this browser, please enable them to open this website
No Prefix Set
You are viewing a single comment's thread. Return to all comments →
trie with python: