1525. Number of Good Ways to Split a String

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

On This Page

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