Gary Lai
  • Home
  • About
Sign in Subscribe

1446. Consecutive Characters

Last updated on  Jan 29, 2023

1446. Consecutive Characters

class Solution:
    def maxPower(self, s: str) -> int:
        prev = s[0]
        count = 1
        res = 1
        for curr in range(1, len(s)):
            if s[curr] == prev:
                count += 1
                res = max(res, count)
            else:
                prev = s[curr]
                count = 1
        return res
Previous 930. Binary Subarrays With Sum
Next 426. Convert Binary Search Tree to Sorted Doubly Linked List
Gary Lai © 2025
  • Sign up
Powered by Ghost