프로그래밍/LeetCode

[LeetCode][Python3] 395. Longest Substring with At Least K Repeating Characters

snoopybox 2019. 3. 28. 01:03

Problem :

https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/


My Solution :

class Solution:
def longestSubstring(self, s: str, k: int) -> int:
if len(s) < k:
return 0
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)
저작자표시 (새창열림)