问题
Here is the code: I am able to find the longest common substring but I would like to find the longest common substring with at most one skip ?
#include <iostream>
using namespace std;
string X,Y;
int lcs(int i, int j, int count)
{
if (i == 0 || j == 0)
return count;
if (X[i-1] == Y[j-1]) {
count = lcs(i - 1, j - 1, count + 1);
}
count = max(count, max(lcs( i, j - 1, 0), lcs( i - 1, j, 0)));
return count;
}
int main()
{
int n,m;
X = "AACBkkkk";
Y = "AABDkkkks";
n=X.size();
m=Y.size();
cout<<lcs(n,m,0);
return 0;
}
来源:https://stackoverflow.com/questions/62495298/how-can-we-calculate-longest-common-substring-with-one-atmost-one-skip