cswork / OA打开练习工作台

RubrikOA #6

Longest Subsequence Matching a Substring

估计中等可在线判题

考点(AI 标注)字符串动规子序列

Given strings x and y, find the maximum length of a subsequence of x that is also a non-empty contiguous substring of y.

输入格式

Two lines with non-empty ASCII strings x and y; added by this site: |x|,|y|≤2000.

输出格式

Output the required length; if no non-empty match exists, output 0.

样例 1

输入:

abcd
abdc

输出:

3

样例 2

输入:

hackerranks
hackers

输出:

7

样例 3

输入:

abc
XYZ

输出:

0