We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f71969 commit a1d3880Copy full SHA for a1d3880
1 file changed
LeetCode/1250-longest-common-subsequence/solution.cpp
@@ -3,16 +3,14 @@ class Solution {
3
int longestCommonSubsequence(string text1, string text2) {
4
int n = text1.size();
5
int m = text2.size();
6
-
7
vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
8
for (int i=1; i<=n; i++) {
9
for (int j=1; j<=m; j++) {
10
dp[i][j] = max(dp[i][j], dp[i-1][j-1] + (text1[i-1] == text2[j-1]));
11
- dp[i][j] = max(dp[i][j], dp[i-1][j]);
12
dp[i][j] = max(dp[i][j], dp[i][j-1]);
+ dp[i][j] = max(dp[i][j], dp[i-1][j]);
13
}
14
15
16
return dp[n][m];
17
18
};
0 commit comments