Consecutive Characters
Input: s = "leetcode"
Output: 2
Explanation: The substring "ee" is of length 2 with the character 'e' only.class Solution:
def maxPower(self, s: str) -> int:
powers = [None for x in range(len(s))]
powers[0] = 1
for i in range(1, len(powers)):
if s[i] == s[i - 1]:
powers[i] = powers[i - 1] + 1
else:
powers[i] = 1
return max(powers)aaab
[4, 5]
i[2] = i[2 - 1] + 1 because "a" at index 2 == "a" at index 1.Last updated