#C2373. Longest Run Length in a String

    ID: 45682 Type: Default 1000ms 256MiB

Longest Run Length in a String

Longest Run Length in a String

Given a string, a run is defined as a maximal consecutive sequence of identical characters. In this problem, you are required to determine the length of the longest run for each input string. Note that an empty string is considered to have a single run of length 1. For example, in the string aaabbcc, the longest run is aaa with a length of 3.

The problem can be formulated using the following expression: $$\max_{1\leq i \leq n} { r_i }$$, where $$r_i$$ represents the length of the run at position i.

inputFormat

The first line of the input contains an integer $$T$$, representing the number of test cases. Each of the following $$T$$ lines contains a single string. An empty line represents an empty string.

outputFormat

For each test case, output a single integer representing the length of the longest run in the corresponding string. Each result should be printed on a new line.## sample

2
aaabbcc
aabbbccddd
3

3

</p>