Problem
Return the length of the longest subsequence that appears in both strings a and b. A subsequence keeps the original order but may skip characters. Return 0 if they share nothing.
Example 1
- Input
- a = "abcde", b = "ace"
- Output
- 3
- Why
- "ace"
Example 2
- Input
- a = "abc", b = "abc"
- Output
- 3
Example 3
- Input
- a = "abc", b = "def"
- Output
- 0
Constraints
0 <= a.length, b.length <= 1000Both strings contain only lowercase letters.