#C828. Longest Run of Identical Characters
Longest Run of Identical Characters
Longest Run of Identical Characters
Given a string s consisting of only lowercase English letters, determine the length of the longest contiguous segment (run) of identical characters in the string.
A run is defined as a maximal consecutive sequence of the same character. For example, in the string "aaabbbaac", the longest run is "aaa" or "bbb" with a length of 3.
Use a simple linear scan algorithm to solve the problem efficiently.
In mathematical terms, if we denote the input string as \(s = s_1s_2\ldots s_n\), you are required to compute:
\[ \max_{1 \leq i \leq n} \{ \text{length of consecutive identical characters starting at } i \} \]inputFormat
The input consists of a single line containing the string s (0 \leq |s| \leq 10^5
), consisting only of lowercase English letters (the line can be empty indicating an empty string).
outputFormat
Output a single integer representing the length of the longest run of identical characters in the string.
## sampleaaabbbaac
3