Skip to content
StackDecode
StringsExplained

Aho–Corasick Algorithm

A trie with failure links that matches many patterns in one pass.

Time

O(n + m + z)

Extra space

O(m)

Use it for

Searching a dictionary of words in text.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.