#P5546. Longest Common Substring Length
Longest Common Substring Length
Longest Common Substring Length
Given a list of words comprised solely of lowercase letters, find the length of their longest common substring.
A substring is a contiguous sequence of characters. If no common substring exists, output 0.
Formally, given words \( S_1, S_2, \ldots, S_n \), find the maximum \( L \) such that there exists a substring of length \( L \) that appears in every \( S_i \).
inputFormat
The first line contains an integer \( n \), the number of words. Each of the next \( n \) lines contains a sentence composed of lowercase letters only.
outputFormat
Output a single integer representing the length of the longest common substring among all words.
sample
3
flower
flow
flight
2