#K37012. Maximum Contiguous Flowers
Maximum Contiguous Flowers
Maximum Contiguous Flowers
You are given a string s representing a row of garden plots, where each character indicates the type of flower in that plot. Your task is to determine the maximum number of contiguous plots that have the same flower type.
In other words, find the longest substring in which every character is identical. Formally, if the string has length \(n\) and is represented as \(s_1s_2\ldots s_n\), you need to compute:
\( \max_{1 \leq i \leq n} \; {\rm length}(\{ j \mid s_j = s_i \text{ and } j \text{ are consecutive} \}) \)
For example, given s = "ABCAAACBB"
, the answer is 3 because the longest contiguous block is "AAA".
inputFormat
The input consists of a single line containing a non-negative string s (which may be empty) where each character represents the type of flower in a plot.
Note: The input should be read from stdin.
outputFormat
Output a single integer representing the maximum number of contiguous plots with the same flower type.
The output should be written to stdout.
## sampleAA
2