动态规划
Do_Not_Quit
We do whatever to stay alive.
展开
-
LCS 最长公共子序列(不连续)
public class LCS { public static int lcs(String str1, String str2) { int len1 = str1.length(); int len2 = str2.length(); int c[][] = new int[len1 + 1][len2 + 1]; for (int i = 0; i <= len1...原创 2018-03-31 22:11:18 · 176 阅读 · 0 评论 -
LCS最长公共子串(连续)
核心代码: if (i == 0 || j == 0) { c[i][j] = 0; } else if (str1.charAt(i - 1) == str2.charAt(j - 1)) { c[i][j] = c[i - 1][j - 1] + 1; result = Math.max(c[i][j], result); ...原创 2018-03-31 22:19:42 · 108 阅读 · 0 评论