递推方程:
0, i = 0 or j = 0
C[i,j] = C[i-1,j-1] + 1, i,j > 0 and Xi = Yj
max{C[i-1,j],C[i,j-1]}, i,j > 0 and Xi != Yj
Xn串和Ym串,从后往前看,如果Xn=Ym,则最长公共子序列为Xn-1和Ym-1串的最长公共子序列加1
时间: 2024-11-05 11:25:08
递推方程:
0, i = 0 or j = 0
C[i,j] = C[i-1,j-1] + 1, i,j > 0 and Xi = Yj
max{C[i-1,j],C[i,j-1]}, i,j > 0 and Xi != Yj
Xn串和Ym串,从后往前看,如果Xn=Ym,则最长公共子序列为Xn-1和Ym-1串的最长公共子序列加1