#include<iostream>
#include<vector>
#include<deque>
#include<limits.h>
#include<string>
using namespace std;
//递归解法
int LCSLength(char X[], char Y[], int i, int j,
vector<vector<int> > &c,vector<vector<int> > &s)
{
if (i == 0 || j == 0) return 0;
else if(c[i][j] > 0) return c[i][j];
else if (X[i] == Y[j])
{
c[i][j] = LCSLength(X, Y, i - 1, j - 1,c,s) + 1;
s[i][j] = 1; //
}
else
{
int maxlen1 = LCSLength(X, Y, i - 1, j,c,s);
int maxlen2
求两个字符串的最长公共子序列(动态规划)
![](https://img-home.csdnimg.cn/images/20240711042549.png)