Introduction
The suffix array stores all suffixes of a string in lexicographic order. It turns many string questions into array questions: substring search becomes binary search, repeated substrings become neighboring suffix comparisons, and the longest common prefix array can answer similarity queries.
We will build it with the prefix-doubling algorithm in .
Problem or motivation
For a string of length , suffix is . We need to print the starting positions of all suffixes in lexicographic order.