Skip to content

Instantly share code, notes, and snippets.

View daniel-abramov's full-sized avatar

Daniel Abramov daniel-abramov

  • Munich, Germany
View GitHub Profile
@daniel-abramov
daniel-abramov / trie.py
Created June 12, 2016 16:24
Simple implementation of trie data structure, O(n) for finding words
class Trie:
def __init__(self):
self.trie = dict()
def insert(self, key, value):
p = self.trie
for c in key:
if c not in p: p[c] = dict()
p = p[c]
p[None] = value