1525. Number of Good Ways to Split a String

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

Содержание

LeetCode problem 1525

class Solution:
    def numSplits(self, s: str) -> int:
        cnt = Counter(s)
        vis = set()
        res = 0
        for c in s:
            vis.add(c)
            cnt[c] -= 1
            if cnt[c] == 0:
                cnt.pop(c)
            res += len(vis) == len(cnt)
        return res