8. Longest Common Subsequence
MediumDynamic ProgrammingString
Print the length of the longest common subsequence of two strings.
Input format
Line 1: string a Line 2: string b
Output format
The LCS length.
Example 1
Input
abcde ace
Output
3
Example 2
Input
abc abc
Output
3
Constraints
1 ≤ |a|, |b| ≤ 1000, lowercase letters
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…