#C7786. Longest Run Length
Longest Run Length
Longest Run Length
Given a string S
, your task is to determine the length of the longest consecutive run of identical characters in the string. A run is defined as a contiguous sequence where all characters are the same. If the input string is empty, the output should be 0
.
Example:
- Input:
aabbbbccddddddeee
— Output:6
- Input:
xyz
— Output:1
Note: Ensure that your solution reads from standard input and prints the result to standard output.
inputFormat
The input consists of a single line containing the string S
. The string may be empty.
outputFormat
Output a single integer representing the length of the longest run of identical characters in S
.
aabbbbccddddddeee
6