We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cee05de commit e7e5e2bCopy full SHA for e7e5e2b
longest-common-subsequence/printjin-gmailcom.py
@@ -0,0 +1,11 @@
1
+class Solution:
2
+ def longestCommonSubsequence(self, text1, text2):
3
+ m, n = len(text1), len(text2)
4
+ dp = [[0] * (n + 1) for _ in range(m + 1)]
5
+ for i in range(1, m + 1):
6
+ for j in range(1, n + 1):
7
+ if text1[i - 1] == text2[j - 1]:
8
+ dp[i][j] = dp[i - 1][j - 1] + 1
9
+ else:
10
+ dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
11
+ return dp[m][n]
0 commit comments