Ctrl K

Longest Same-Letter Streak

Easy
You get a string text of lowercase English letters. A streak is a run of identical letters standing next to each other. Return the length of the longest streak. A single letter on its own counts as a streak of length 1.
Example 1
text="zzzzaaabzzz" → 4

The longest streak is the four z's at the start; the three a's and the trailing z's are shorter.

Example 2
text="moon" → 2

Only the two o's stand next to each other.

Example 3
text="q" → 1
Constraints
  • 1 ≤ len(text) ≤ 500
  • text consists of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
text="zzzzaaabzzz"
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.