1400 - Longest common prefix

Time Limit: 2s Memory Limit: 128MB

Submissions: 722 Solved: 137
Description

       Given N string S[1], S[2]......, S[N], you are to find a pair of strings whose longest common prefix has the largest length.

Input

       There are multiple test cases. For each case:

       The first line is a integer N. (2 <= N <= 20000)

       The next N lines each contains a non-empty string S[i]. The length of S[i] is at most 50.

Output

       For each case output a line representing the length of longest common prefix.

Sample Input
3
bcabc
bcd
abcd
Sample Output
2
Hint
Source
Xiaobin YANG