Problem K
Longest Common Subsequence
You are given
String
Compute the length of the longest common
subsequence of all
Input
The first line of input contains two integers
Each of the next
Output
Output a single integer, the length of the longest
subsequence that appears in all
Sample Input 1 | Sample Output 1 |
---|---|
2 3 BAC ABC |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
3 8 HGBDFCAE ADBGHFCE HCFGBDAE |
3 |
Sample Input 3 | Sample Output 3 |
---|---|
6 8 AHFBGDCE FABGCEHD AHDGFBCE DABHGCFE ABCHFEDG DGABHFCE |
4 |