suffixautomaton
The suffix automaton is a data structure in computer science that represents all substrings of a given string. It is a minimal finite automaton, meaning it has the smallest possible number of states, that accepts precisely the set of all substrings of a string. The suffix automaton is a directed acyclic graph where each edge is labeled with a single character. The states in the automaton represent sets of substrings, and paths from the initial state to any other state spell out substrings.
Constructing a suffix automaton for a string of length n can be done in linear time, O(n).
The suffix automaton is closely related to other string data structures like suffix trees and suffix arrays.