Lets play a Game
Submissions: 233   Accuracy:

15.02%

  Difficulty: Hard
     

Three friends got bored with their old card games, so decided to invent a new game. Let the name of three friends be player 1, player 2 and player 3.

In this new game, there are 26 different types of cards with infinite supply of every card. Each friend picks random number of cards in random order. They want to find out how close first two friends(player 1 and player 2) are with respect to the third friend(player 3). For this, they need to find the longest common subsequence of cards, that appears in the cards picked by first two friends(player 1 and player 2), without disturbing the order of given cards. Let us call this series as deck. But this deck should not be the string formed by the cards picked by third friend(player 3).

Input:
First line consists of T test cases. 
Next Three lines of input consisting of three string of player 1, 2 and 3 respectively. (Only uppercase letters).

Output:
Print the length of the final string(deck) formed, if not possible print 0.

Constraints:
1<=T<=10
1<=|String|<=100

Example:
Input:
1
ABC
ACB
AB
Output:
2

Explaination :

All the possible subsequence are A, B, C, AC , AB.

Therefore, AC whose length is 2 is different from the series of Player 3. 

Ans : Length is 2.

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

Author: Contribute.Practice


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