1933. Check if String Is Decomposable Into Value-Equal Substrings

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1933

class Solution:
    def isDecomposable(self, s: str) -> bool:
        cnt2 = 0
        for _, g in groupby(s):
            m = len(list(g))
            if m % 3 == 1:
                return False
            cnt2 += m % 3 == 2
            if cnt2 > 1:
                return False
        return cnt2 == 1