SalesforceOA #12
Find Longest Subsequence Common to X as Substring in Y
估计中等可在线判题
Find the longest string s that is both a subsequence of X and a contiguous substring of Y, and return its length. The original text of this entry has only a title, function name, and examples. When there is no match, the length is 0.
输入格式
Two lines, X and Y respectively. On this site both are non-empty lowercase strings of length 1..2000.
输出格式
Output the maximum length.
样例 1
输入:
hackerranks
hackers
输出:
7
样例 2
输入:
abcd
abdc
输出:
3
样例 3
输入:
abc
zz
输出:
0
样例说明
The answers are 7, 3, and 0; in the second example, abd is a subsequence of X and a contiguous substring of Y.