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).
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).
Print the length of the final string(deck) formed, if not possible print 0.
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.
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.