public static String lcs(String s,String t){
  SuffixArray suffix1=new SuffixArray(s);
  SuffixArray suffix2=new SuffixArray(t);
  String lcs="";
  int i=0, j=0;
  while (i < s.length() && j < t.length()) {
    int p=suffix1.index(i);
    int q=suffix2.index(j);
    String x=lcp(s,p,t,q);
    if (x.length() > lcs.length())     lcs=x;
    if (compare(s,p,t,q) < 0)     i++;
 else     j++;
  }
  return lcs;
}

public static String lcs ( String s , String t ) { SuffixArray suffix1 = new SuffixArray ( s ) ; SuffixArray suffix2 = new SuffixArray ( t ) ; String lcs = "" ; int i = 0 , j = 0 ; while ( i < s . length ( ) && j < t . length ( ) ) { int p = suffix1 . index ( i ) ; int q = suffix2 . index ( j ) ; String x = lcp ( s , p , t , q ) ; if ( x . length ( ) > lcs . length ( ) ) lcs = x ; if ( compare ( s , p , t , q ) < 0 ) i ++ ; else j ++ ; } return lcs ; }
returns the longest common string of the two specified strings .
