The string is ‘RR’, ‘RB’ so we can combine ‘RR’ and ‘RB’ as the last character of ‘RR’ i.e ‘R’ matches with the first character of ‘RB’. But we cant combine ‘RB’ and ‘RR’ as the last character of ‘RB’ i.e ‘B’ doesn't matches with the first character of ‘RR’ i.e ‘R’ so our answer is '4'.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains an integer ‘N’ denoting the number of strings.
The second line of each test case contains ‘N’ space-separated strings.
For each test case, print a single line containing a single integer denoting the maximum length of string which can be formed. In case no two strings can add simply print ‘0’.
The output of each test case will be printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 100
2 <= N <= 1000
1 <= | ST | <= 1000
Where ‘T’ represents the number of test cases and ‘N’ represents the total number of strings and '|ST|' represents the length of each of the ‘N’ strings.
Time Limit: 1 second
We have to find out the maximum length of string which can be formed by joining two strings if the first character of the first string is equal to the last character of the second string.
Divisible Substrings
Ninja and Numbers
Longest Palindromic Substring
Cakes
1-3 Palindrome