If you have a suffix array that contains all the suffixes of every input string, then for any string X that is a (contiguous) substring of all the input strings, there is a contiguous subarray in which every suffix starts with X, that includes a suffix from every input string.
Furthermore, if X is a longest common substring, then the subarray can be as small as possible, such that the first and last suffixes in the subarray are the only suffixes from their corresponding input strings.
To find the longest substring, then:
- For each position in the suffix array, find the smallest subarray starting at that position that includes a suffix from every string. You can use the incrementing-two-pointers technique to do this in amortized constant time per entry.
- For each such subarray, find the longest common prefix of the first and last entries, which will be a common prefix of every item in the subarray.
- Remember the longest common prefix you find, which is the longest substring that occurs in every input.