class Solution:
def longestSubstring(self, s: str, k: int) -> int:
def divide(s):
counter=Counter(s)
length=0
for key,val in counter.items():
if val<k:
strs=s.split(key)
for string in strs:
length=max(length,divide(string))
return length
return len(s)
return divide(s)
注意这个递归写法