Package edu.princeton.cs.algs4
Class LongestRepeatedSubstring
- Object
-
- edu.princeton.cs.algs4.LongestRepeatedSubstring
-
public class LongestRepeatedSubstring extends Object
TheLongestRepeatedSubstringclass provides aSuffixArrayclient for computing the longest repeated substring of a string that appears at least twice. The repeated substrings may overlap (but must be distinct).For additional documentation, see Section 6.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
See also
LongestCommonSubstring.- Author:
- Robert Sedgewick, Kevin Wayne
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringlrs(String text)Returns the longest repeated substring of the specified string.static voidmain(String[] args)Unit tests thelrs()method.
-
-
-
Method Detail
-
lrs
public static String lrs(String text)
Returns the longest repeated substring of the specified string.- Parameters:
text- the string- Returns:
- the longest repeated substring that appears in
text; the empty string if no such string
-
main
public static void main(String[] args)
Unit tests thelrs()method.- Parameters:
args- the command-line arguments
-
-