Definition at line 5 of file main.cpp.
◆ longestCommonSubsequence()
| int Solution::longestCommonSubsequence |
( |
string |
text1, |
|
|
string |
text2 |
|
) |
| |
|
inline |
Definition at line 8 of file main.cpp.
9 {
10 vector<vector<int>> dp((int)text1.size() + 1, vector<int>((int)text2.size() + 1, 0));
11 for (int i = (int)text1.size() - 1; i >= 0; --i)
12 for (int j = (int)text2.size() - 1; j >= 0; --j)
13 if (text1[i] == text2[j])
14 dp[i][j] = 1 + dp[i + 1][j + 1];
15 else
16 dp[i][j] = max(dp[i][j + 1], dp[i + 1][j]);
17 return dp[0][0];
18 }
Referenced by main().
The documentation for this class was generated from the following file: