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

Updated: 2024-03-12
1 min read
[]

On This Page

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