核心在于子序列不连续,子串连续
if(a[i]== a[j]){
dp[i][j] = dp[i-1][j-1]+1
}
else {
//子串
dp[i][j]=0;
//子序列
dp[i][j]=max(dp[i-1][j],dp[i][j-1])
https://leetcode-cn.com/problems/longest-common-subsequence/
核心在于子序列不连续,子串连续
if(a[i]== a[j]){
dp[i][j] = dp[i-1][j-1]+1
}
else {
//子串
dp[i][j]=0;
//子序列
dp[i][j]=max(dp[i-1][j],dp[i][j-1])
https://leetcode-cn.com/problems/longest-common-subsequence/