Longest Common Subsequence
Medium
LC #1143
two strings2d dpNot attempted yet
Return the length of the longest common subsequence of
text1 and text2, or 0 if they share none. A
subsequence keeps the original order but may skip
characters ("ace" is a subsequence of "abcde").
Example 1
Input: text1 = "abcde", text2 = "ace"
Output: 3
"ace"
Example 2
Input: text1 = "abc", text2 = "abc"
Output: 3
Example 3
Input: text1 = "abc", text2 = "def"
Output: 0
Constraints
- 1 ≤ len(text1), len(text2) ≤ 1000
- lowercase letters only