Longest Common Subsequence
Submit solution
Points:
1
Time limit:
2.0s
Memory limit:
256M
Problem type
Allowed languages
C++, Python
Longest Common Subsequence
Given two strings A and B of lengths N and M respectively, find the length of the longest string that is a subsequence of both A and B.
Input Format
The first line contains two integers N and M.
The second line contains a string of length N, representing string A.
The third line contains a string of length M, representing string B.
The strings consist of lowercase letters.
Output Format
Output an integer representing the maximum length.
Constraints
1 ≤ N, M ≤ 1000
Sample Input
4 5
acbd
abedc
Sample Output
3
Comments