#K44452. Longest Contiguous Subsequence of Marbles

    ID: 27534 Type: Default 1000ms 256MiB

Longest Contiguous Subsequence of Marbles

Longest Contiguous Subsequence of Marbles

You are given a collection of sequences, where each sequence represents a row of marbles with colors indicated by uppercase letters. Your task is to identify, for each sequence, the length of the longest contiguous subsequence where all the marbles are of the same color.

Formally, if a sequence is represented as a string \(S\) of length \(n\), you need to compute the maximum integer \(L\) such that there exists an index \(i\) (\(1 \le i \le n-L+1\)) for which \(S[i] = S[i+1] = \cdots = S[i+L-1]\). For example, in the sequence "AABBBCC", the longest contiguous block is "BBB" with a length of 3.

inputFormat

The first line of input contains a single integer \(T\) (\(T \ge 1\)), representing the number of sequences. This is followed by \(T\) lines, each containing a non-empty string composed of uppercase letters that represent a sequence of marbles.

outputFormat

Output \(T\) integers separated by a space. Each integer is the length of the longest contiguous subsequence of marbles with the same color in the corresponding input sequence.

## sample
3
AABBBCC
ABBACCC
AABBBA
3 3 3

</p>