Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Trie solution in Speedy category for The End of Other by dagger126
from collections import defaultdict
class TrieNode:
def __init__(self):
self.children = defaultdict(TrieNode)
self.is_word = False
def checkio(words_set):
def insert(word):
current = root
for letter in word:
current = current.children[letter]
if current.is_word:
return True
current.is_word = True
return current.children
root = TrieNode()
return any(insert(w[::-1]) for w in words_set)
Aug. 17, 2015