Skip to content

Commit a1d3880

Browse files
Sync LeetCode submission Runtime - 31 ms (37.97%), Memory - 27.3 MB (68.47%)
1 parent 3f71969 commit a1d3880

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

LeetCode/1250-longest-common-subsequence/solution.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ class Solution {
33
int longestCommonSubsequence(string text1, string text2) {
44
int n = text1.size();
55
int m = text2.size();
6-
76
vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
87
for (int i=1; i<=n; i++) {
98
for (int j=1; j<=m; j++) {
109
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]);
1210
dp[i][j] = max(dp[i][j], dp[i][j-1]);
11+
dp[i][j] = max(dp[i][j], dp[i-1][j]);
1312
}
1413
}
15-
1614
return dp[n][m];
1715
}
1816
};

0 commit comments

Comments
 (0)