less than 1 minute read

Given a lowercase alphabet string s, return the length of the longest substring with same characters.

Constraints

  • 0 ≤ n ≤ 100,000 where n is the length of s

https://binarysearch.com/problems/Longest-Consecutive-Duplicate-String

Examples

Example 1

Input

  • s = aaabbb

Output

  • answer = 3

Example 2

Input

  • s = abbbba

Output

  • answer = 4

Explanation

The longest substring is "bbbb".

Solution

Leave a comment