#K81722. Longest Horizontal Contiguous Identical Characters
Longest Horizontal Contiguous Identical Characters
Longest Horizontal Contiguous Identical Characters
Given a grid with m rows and n columns, where each row is a string of characters, your task is to find the length of the longest contiguous sequence of identical characters in any row.
For example, in the row "aabbbcc", the longest contiguous sequence is "bbb" with a length of 3. Formally, if you denote the grid by $G$, you are to compute:
$$\max_{1 \leq i \leq m} \max_{1 \leq j \leq n}\, (\text{length of contiguous segment in } G[i])$$
Note: The input constraints are such that $1 \leq m, n \leq 10^3$. Use efficient methods to avoid timeouts.
inputFormat
The first line contains two integers m and n separated by a space, denoting the number of rows and columns respectively.
Each of the next m lines contains a string of exactly n characters representing that row of the grid.
outputFormat
Output a single integer which is the length of the longest contiguous sequence of identical characters found in any row.
## sample3 4
abab
bbbb
abcd
4