标签:com solution return long stc ext1 ems common class
class Solution {
public:
int f[1005][1005];
int longestCommonSubsequence(string text1, string text2) {
memset(f,0,sizeof(f));
int n=text1.size();
int m=text2.size();
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(text1[i-1]==text2[j-1]){
f[i][j]=max(f[i][j],f[i-1][j-1]+1);
}else{
f[i][j]=max(f[i][j],max(f[i-1][j],f[i][j-1]));
}
}
return f[n][m];
}
};
标签:com solution return long stc ext1 ems common class
原文地址:https://www.cnblogs.com/rign-lr7rq2truq/p/14382297.html