类 LongestCommonSubstring
- java.lang.Object
-
- edu.princeton.cs.algs4.LongestCommonSubstring
-
public class LongestCommonSubstring extends java.lang.ObjectTheLongestCommonSubstringclass provides aSuffixArrayclient 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.
-
-
方法详细资料
-
lcs
public static java.lang.String lcs(java.lang.String s, java.lang.String t)Returns the longest common string of the two specified strings.- 参数:
s- one stringt- the other string- 返回:
- the longest common string that appears as a substring
in both
sandt; the empty string if no such string
-
main
public static void main(java.lang.String[] args)
Unit tests thelcs()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
-
-