#K78657. Longest Consecutive Character Sequence
Longest Consecutive Character Sequence
Longest Consecutive Character Sequence
In this problem, you are given a string and you need to determine the length of the longest sequence of consecutive identical characters. Formally, given a string ( s ) of length ( n ) consisting of lowercase English letters, find the maximum length ( L ) such that there exists an index ( i ) with ( s[i] = s[i+1] = \cdots = s[i+L-1] ).
The problem requires careful iteration over the string and maintaining a count of consecutively repeated characters. It tests both your array/string manipulation skills and your ability to work with simple iterative algorithms.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains a single integer ( n ), indicating the length of the string. The second line contains the string ( s ) which is made up of lowercase English letters. Note that ( n ) may be zero, in which case the string is empty.
outputFormat
Output to standard output (stdout) a single integer representing the length of the longest sequence of consecutive identical characters in the string.## sample
6
aaabbc
3