Skip to content
StackDecode
Advanced data structuresExplained

Suffix Automaton

The smallest automaton accepting all suffixes of a string.

Time

O(n)

Extra space

O(n)

Use it for

Substring counting and matching.

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.