Untitled
unknown
plain_text
a year ago
462 B
9
Indexable
from collections import defaultdict
class Solution:
def numSplits(self, s: str) -> int:
ldict = defaultdict(int)
rdict = defaultdict(int)
goodsplits = 0
for ch in s:
rdict[ch] += 1
for ch in s:
ldict[ch] += 1
rdict[ch] -= 1
if rdict[ch] == -1:
del rdict[ch]
if len(ldict.keys()) == len(rdict.keys()):
goodsplits += 1Editor is loading...
Leave a Comment