Skip to content

Instantly share code, notes, and snippets.

@kunigami

kunigami/fail_edge.txt

Last active Nov 9, 2019
Embed
What would you like to do?
queue = [root]
while queue is not empty:
r = queue.pop()
for each a in symbols:
let p = ps(r)
while g(p, a) is none:
p = ps(p)
// s = r + a is not in the trie
if g(r, a) is none:
f(r, a) = p
else:
s = g(r, a)
ps(s) = g(p, a)
queue.push(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.