Longest Common Subsequence

easy
1.Given two Strings
 2.Find the length of longest subsequence present in both of them.
 3.Both the strings are of uppercase.
 4.You have to complete the function lcs() which should return the length of the longest common subsequence.

Input Format

1.First line contains two space separated Integers 'A' and 'B' deonting the size of two strings. 2.Next two lines contains strings A and B.

Output Format

Return an Integer

Constraints

1<=size(str1),size(str2)<=100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
6 6
ABCDGH
AEDFHR
Output
3
Previous
Count Palindromic Subsequences
Next
Longest Common Substring

Related Questions