1525. Number of Good Ways to Split a String
On This Page
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