Substring - Subsequence problem
Medium Accuracy: 27.26% Submissions: 1818 Points: 4

Manoj, Vinoj and Jegan are the famous coders of TCE. One fine day Vinoj and Jegan challenge Manoj to solve a puzzle. That is Vinoj will select one string A. Similarly Jegan will choose one string B with the same size. You need to help Manoj to find the longest subsequence X of a string A which is a substring Y of a string B. 

Example
A : ABCD
B : BACDBDCD
The answer would be 3 as because 'ACD' is the longest subsequence of A which is also a substring of B.


Input:
The first line of input contains an integer T. Then T test cases follow. Each test case contains two space separated strings A and B.

Output:
For each test case in a new line print the required output.

Constraints:
1<=T<=12
1<=Length of strings <=100

Example:
Input:

2
ABCD BACDBDCD
A A
Output:
3
1

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.