Problem statement

https://binarysearch.com/problems/Longest-Consecutive-Duplicate-String/

Solution

We can use groupby to find the longest group/

Complexity

It is O(n) for time and space.

Code

class Solution:
    def solve(self, s):
        return max(len(list(y)) for x, y in groupby(s)) if s else 0