Timer is Running

LCS of three strings
Submissions: 5799   Accuracy:

38.74%

  Difficulty: Medium   Marks: 4
Associated Course(s):   Geeks Classes

Given 3 strings X, Y and Z, the task is to find the longest common sub-sequence in all three given sequences.

 

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains integers n, m and k denoting the length of strings X, Y and Z respectively.

The second line of each test case contains the three strings X, Y and Z. The string consists of only lower case english alphabets.

Output:

Print the length of the longest common sub- sequence of the three strings for each test case in a new line.


Constraints:
1<= T <=100
1<= N, M, K <=100


Example:
Input:
1
5 8 13
geeks geeksfor geeksforgeeks

Output:
5

Explanation:
All the 3 strings given have "geeks" as the longest subsequence present which has a length of 5.
geeks geeksfor geeksforgeeks

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

Contributor: Sujnesh Mishra
Author: sujnesh


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.