Print all LCS sequences
Submissions: 1536   Accuracy:

17.64%

  Difficulty: Hard   Marks: 8

You are given two strings a and b. Now your task is to print all longest common sub-sequences in lexicographical order.

Input:
The first line of input contains an integer denoting the no of test cases T. Then T test case follow each test case contains 2 space separated strings a and b.

Output:
For each test case in a new line  print the space separated sequences.

Constraints:
1<=T<=100
1<=length of strings a and b<=100

Example:
Input:

2
abaaa baabaca
aaa a
Output:
aaaa abaa baaa
a

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

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.