Longest Common Subsequence
Given two strings a
and b
, return the length of their longest common subsequence.
Constraints
n ≤ 1,000
wheren
is the length ofa
m ≤ 1,000
wherem
is the length ofb
https://binarysearch.com/problems/Longest-Common-Subsequence
Examples
Example 1
Input
- a =
abcvc
- b =
bv
Output
- answer =
2
Explanation
bv
is the longest common subsequence.
Example 2
Input
- a =
abc
- b =
abc
Output
- answer =
3
Example 3
Input
- a =
abc
- b =
def
Output
- answer =
0
Example 4
Input
- a =
binarysearch
- b =
searchbinary
Output
- answer =
6
Leave a comment