A suffix array will index all the suffixes for a given list of strings, but what if you\'re trying to index all the possible unique substrings? I\'m a bit new at this, so h
You should use a variation of 'Trie'. Essentially, if you have ABCD, create tree which is a merger of paths: root->A->B->C->D, root->B->C->D, root->C->D and root->D. Now, at every node keep a list of locations where string root->.->.->node was observed.