题目描述
Find the longest subsequence X of a string A which is a substring Y of a string B.
Note: All letters of the Strings are Uppercased.
Example 1:
Input:
A = "ABCD" , B = "BACDBDCD"
Output:
3
Explanation:
The answer would be 3 as because "ACD"
is the longest subsequence of A which
is also a substring of B.
Example 2:
Input:
A = "A" , B = "A"
Output:
1
Explanation:
The answer would be 1 as because "A"
is the longest subsequence of A which
is also a substring of B.
Your Task:
You don't need to read input or print anything. Your task is to complete the function getLongestSubsequence() which takes Strings A and B as input and returns the answer.
Expected Time Complexity: O(|S|^{2})
Expected Auxiliary Space: O(|S|^{2})
Constraints:
1 <= |A|,|B| <= 10^{3}
输入格式
见题面
输出格式
见题面