Class LongestRepeatedSubstring

  • public class LongestRepeatedSubstring
    extends Object
    The LongestRepeatedSubstring class provides a SuffixArray client 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.

    Robert Sedgewick, Kevin Wayne
    • Method Detail

      • lrs

        public static String lrs​(String text)
        Returns the longest repeated substring of the specified string.
        text - the string
        the longest repeated substring that appears in text; the empty string if no such string
      • main

        public static void main​(String[] args)
        Unit tests the lrs() method.
        args - the command-line arguments