public class LongestCommonSubstring extends Object
LongestCommonSubstringclass provides a
SuffixArrayclient for computing the longest common substring that appears in two given strings.
This implementation computes the suffix array of each string and applies a merging operation to determine the longest common substring. For an alternate implementation, see LongestCommonSubstringConcatenate.java.
For additional documentation, see Section 6.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
|Modifier and Type||Method and Description|
Returns the longest common string of the two specified strings.
Unit tests the
s- one string
t- the other string
t; the empty string if no such string
public static void main(String args)
lcs()method. Reads in two strings from files specified as command-line arguments; computes the longest common substring; and prints the results to standard output.
args- the command-line arguments