1143. Longest Common Subsequence
Practice Longest Common Subsequence for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
A subsequence keeps some characters of a string in their original order, possibly dropping others. Return the length of the longest string that is a subsequence of both text1 and text2, or 0 if they share no characters.
Example
text1 = "abcde", text2 = "ace" -> 3 ("ace")
text1 = "abc", text2 = "def" -> 0
Constraints
- 1 <= text1.length, text2.length <= 500
- Both strings are lowercase English letters