题目链接:
力扣https://leetcode-cn.com/problems/consecutive-characters/
【分析】今天的题过于简单了,一次遍历即可
class Solution:
def maxPower(self, s: str) -> int:
cur = ''
ans, t = 0, 1
for i in s:
if i == cur:
t += 1
else:
ans = max(ans, t)
t = 1
cur = i
return max(t, ans)