'''
Description:
Autor: Au3C2
Date: 2021-02-27 10:33:43
LastEditors: Au3C2
LastEditTime: 2021-02-27 10:34:37
'''
class Solution:
def longestSubstring(self, s: str, k: int) -> int:
stack = [s]; ans = 0
while stack:
s = stack.pop()
for c in set(s): # 遍历s中的唯一字母
if s.count(c) < k:
temp = []
for t in s.split(c):
if t:
temp.append(t)
stack.extend(temp)
break
else:
ans = max(ans, len(s))
return ans
# 递归,中等,每日一题
# 这解法一点也不递归?
# https://leetcode-cn.com/problems/longest-substring-with-at-least-k-repeating-characters/