Skip to content

Instantly share code, notes, and snippets.

string getLongestCommonSubString(string a, string b)
{
/*
dp[i, j] 为a[0, i - 1] 与 b[0, j - 1]末尾连续相等元素的数量
dp[i, j] = 0 (a[i] != b[j])
dp[i, j] = dp[i - 1, j - 1] + 1 (a[i] == b[j])
*/
vector<vector<int>> dp(a.length() + 1, vector<int>(b.length() + 1, 0));
int index = 0;