48. Longest Common Subsequence
MediumDynamic programming
Return the length of the longest subsequence (characters in order, not necessarily adjacent) common to strings a and b.
Example 1
Input: a = "abcde", b = "ace" Output: 3 Explanation: "ace"
Example 2
Input: a = "abc", b = "def" Output: 0
Constraints
1 ≤ a.length, b.length ≤ 1000