Substring - Subsequence problem
Submissions: 1600   Accuracy:

26.6%

  Difficulty: Medium   Marks: 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

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mr_MaJ
Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.