#K67827. Longest Uniform Substring
Longest Uniform Substring
Longest Uniform Substring
You are given a string s
consisting of lowercase characters. Your task is to determine the length of the longest substring where all the characters are identical. In other words, find the maximum number of consecutive occurrences of the same character in the string.
For example, given the input string \(s = ababbccaa\)
, the longest uniform substring is "cc" or "aa" with a length of 2.
The problem can be formalized as follows:
Given a string \(s\) of length \(n\), find \(L = \max_{\text{all substrings}}(\text{length of substring if all characters are equal})\). If \(s = \varepsilon\) (empty string), then \(L = 0\).
Your solution should read the input from standard input (stdin) and write the result to standard output (stdout).
inputFormat
The input consists of a single line containing the string s
. The string may contain only lowercase letters. It is guaranteed that the input will be provided via standard input (stdin).
outputFormat
Output a single integer which is the length of the longest contiguous substring that contains the same character. Print the answer to standard output (stdout).
## sampleababbccaa
2