Power of String
Easy
string
consecutive-count
run-length
maximum
Problem Description
A string's "power" is defined as the length of the longest run of identical consecutive characters. Find the maximum power in the given string.
Input Format
A single string containing lowercase letters.
Output Format
The power of the string (length of longest consecutive identical characters).
Constraints
• 1 ≤ string length ≤ 1000
• String contains only lowercase letters
• Count consecutive identical characters
• Return maximum run length found
• Single character has power 1
Sample Input/Output
Input:
abbcccdddde
Output:
4
Explanation
Runs: a(1), bb(2), ccc(3), dddd(4), e(1). Maximum run length is 4.
Solution Hints
55
Points
Points
1000ms
Time Limit
Time Limit
64MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now