#C4519. Longest Homogeneous Substring
Longest Homogeneous Substring
Longest Homogeneous Substring
In this problem, you are given a string S, and your task is to find the length of the longest contiguous substring in which all characters are identical. For instance, in the string aabbbcc
, the longest substring of identical characters is bbb
which has a length of 3.
Formally, if we denote the string as ( S = s_1 s_2 \ldots s_n ), you need to determine the maximum integer ( k ) such that for some index ( i ) (with ( 1 \leq i \leq n-k+1 )), the condition ( s_i = s_{i+1} = \cdots = s_{i+k-1} ) holds.
inputFormat
The first line contains an integer ( T ) indicating the number of test cases. Each of the following ( T ) lines contains a string ( S ). Each string consists of at least one character and contains only ASCII letters.
outputFormat
For each test case, output a single line containing one integer: the length of the longest homogeneous (i.e. identical characters) substring in the input string.## sample
3
aabbbcc
aaaa
abcde
3
4
1
</p>