题目
类型:动态规划
题意:求连续的最长公共子串
class LongestSubstring {
public:
int findLongest(string A, int n, string B, int m) {
int res = 0;
vector<vector<int>> dp(n+1, vector<int>(m+1));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(A[i] == B[j]) dp[i+1][j+1] = dp[i][j] +1;
res = max(res, dp[i+1][j+1]);
}
}
return res;
}
};