LeetCode: 395. Longest Substring with At Least K Repeating Characters

原文转载自 「Neo Fung's Blog」 (https://www.neofung.org/2016/09/20/leetcode-395-longest-substring-least-k-repeating-characters/)

预计阅读时间 0 分钟(共 0 个字, 0 张图片, 0 个链接)

1
2
3
4
5
6
7
8
9
10
11
class Solution(object):
def longestSubstring(self, s, k):
"""
:type s: str
:type k: int
:rtype: int
"""
for c in set(s):
if s.count(c) <k:
return max([self.longestSubstring(t, k) for t in s.split(c)])
return len(s)
more_vert