Consecutive Characters
Problem statement
The power of a string is the maximum length of a nonempty contiguous substring containing only one repeated character. Return the power of text. Return 0 for an empty string.
Function
maxConsecutivePower(text: String) → intExamples
Example 1
text = "abbcccddddeeeeedcba"return = 5The longest run is five e characters.
Constraints
0 <= text.length <= 10^5.