#K76292. Longest Consecutive Repeating Characters
Longest Consecutive Repeating Characters
Longest Consecutive Repeating Characters
Given a string S of length N, determine the length of the longest contiguous segment where the same character repeats. Formally, if S is represented as a sequence of characters \(S_1, S_2, \ldots, S_N\), find:
$$L = \max_{1 \le i \le N} \ell(i)$$where \(\ell(i)\) represents the length of the contiguous segment starting at position \(i\) that has all identical characters.
You are given multiple test cases. For each test case, the first input line contains an integer N and the next line contains the string S.
inputFormat
The input begins with an integer T denoting the number of test cases.
Each test case consists of two lines:
- The first line contains an integer N, representing the length of string S.
- The second line contains the string S.
outputFormat
For each test case, output a single line containing the integer which is the length of the longest sequence of consecutive repeating characters in S.
## sample2
8
aaabbcdd
4
aabb
3
2
</p>