Simple example
Input
lcs_length("abcde", "ace")
Output
3
The LCS is "ace" which has length 3.
Full lesson preview
Compute the length of the longest common subsequence (LCS) between two strings using dynamic programming.
Problem statement
Task
Examples
Input
lcs_length("abcde", "ace")
Output
3
The LCS is "ace" which has length 3.
Input format
Output format
Constraints
Samples
Input
lcs_length("ABCBDAB", "BDCABA")
Output
4
One LCS is "BCBA" or "BDAB", both length 4.