updated longest common substring code (suffix array)