https://leetcode.com/problems/consecutive-characters/
The power of the string is the maximum length of a non-empty substring that contains only one unique character.
Given a string s, return the power of s.
time complexity: O(n)
class Solution:
def maxPower(self, s: str) -> int:
power = 1
prev = s[0]
curr_power = 1
for c in s[1:]:
if c == prev:
curr_power += 1
else:
power = max(curr_power, power)
curr_power = 1
prev = c
return max(power, curr_power)