#K84637. Longest Repeated Subsequence
Longest Repeated Subsequence
Longest Repeated Subsequence
You are given T test cases. For each test case, you are provided an integer ( n ) followed by ( n ) strings. Your task is to determine the length of the longest string that appears at least twice among the provided ( n ) strings. If there is no string that appears at least twice, output 0.
In other words, for each test case, find the maximum ( |s| ) such that the string ( s ) occurs at least two times.
inputFormat
The input begins with an integer ( T ) (the number of test cases). For each test case, the first line contains an integer ( n ) (the number of strings). This is followed by ( n ) lines, each containing a single string.
outputFormat
For each test case, output a single integer on a new line representing the length of the longest repeated string. If no string is repeated, output 0.## sample
2
4
abcd
abcd
efgh
efgh
5
zzyy
zzyy
xxyx
aaaa
bbbb
4
4
</p>