Number of Good Ways to Split a String LeetCode solution in Python
1class Solution:2def numSplits(self, s: str) -> int:3one = set()4two = set()5dic = {}67for i in s:8dic[i] = dic.get(i, 0) + 19two.add(i)10tot = 01112for i in s:13one.add(i)14dic[i] -= 115if dic[i] == 0:16two.remove(i)1718if len(one) == len(two):19tot += 120return tot