class Solution:
def checkForSame(self, a, b):
count_a = 0
count_b = 0
for i in range(len(a)):
if a[i]>0:
count_a+=1
if b[i]>0:
count_b+=1
return count_a == count_b
def numSplits(self, s: str) -> int:
a = [0] * 27
b = [0] * 27
ans= 0
for i in range(len(s)):
a[ord(s[i]) - 97]+=1
for i in range(len(s)):
ind = ord(s[i]) - 97
a[ind] -=1
b[ind]+=1
if self.checkForSame(a, b):
ans+=1
return ans
1245C - Constanze's Machine | 1005A - Tanya and Stairways |
1663F - In Every Generation | 1108B - Divisors of Two Integers |
1175A - From Hero to Zero | 1141A - Game 23 |
1401B - Ternary Sequence | 598A - Tricky Sum |
519A - A and B and Chess | 725B - Food on the Plane |
154B - Colliders | 127B - Canvas Frames |
107B - Basketball Team | 245A - System Administrator |
698A - Vacations | 1216B - Shooting |
368B - Sereja and Suffixes | 1665C - Tree Infection |
1665D - GCD Guess | 29A - Spit Problem |
1097B - Petr and a Combination Lock | 92A - Chips |
1665B - Array Cloning Technique | 1665A - GCD vs LCM |
118D - Caesar's Legions | 1598A - Computer Game |
1605A - AM Deviation | 1461A - String Generation |
1585B - Array Eversion | 1661C - Water the Trees |