I hereby claim:
- I am seve on github.
- I am severiano (https://keybase.io/severiano) on keybase.
- I have a public key whose fingerprint is 650D A0D4 5AB9 CF15 2038 53AC 30A1 CD8F 46EE E4DD
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
def add_word(self, word): | |
# print('INSERTING WORD', word) | |
# Set current node to the root node | |
curr_node = self.root | |
# Iterate over the letters in the word | |
for i, letter in enumerate(word): | |
found_letter = False | |
# Look at all the children of the currrent node | |
for j, node in enumerate(self[curr_node]): | |
# If the node's letter and the current letter are the same |
class MyTrie(dict): | |
def __init__(self, word_list=None): | |
super(MyTrie, self).__init__() | |
self.id = 0 | |
# the charcter, a unique id, end charcter in a word | |
self.root = ('', self.id, False) | |
self[self.root] = [] | |
self.id += 1 |