Common Subsequence
Submissions: 6319   Accuracy:

41.86%

  Difficulty: Easy   Marks: 2

Given two strings a and b print whether they contain any common subsequence (non empty) or not.

Input:
The first line contains an integer T denoting number of testcases. Each of the next T lines contains two strings a and b.

Output:
Print 1 if they have a common subsequence (non empty) else 0.

Constraints:
1<=T<=10^5
1<= |a|=|b| <=30
a and b consist of uppercase English letters ('A'....'Z')

Example:
Input:
1
ABEF CADE
Output:
1

Explanation:
AE is a subsequence of both the string so the answer is 1.

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

Contributor: ShivamKD
Author: Dharmesh


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.