2025-08-03 10:25:11 +0000 UTC

Consecutive Characters

Code

class Solution:
    def maxPower(self, s: str) -> int:
        prev = s[0]
        count = 1
        max_count= 1
        for char in s[1:]:
            if char == prev:
                count += 1
                max_count = max(max_count, count)
            else:
                count = 1
                prev = char
        return max_count