Longest Substring with At Least K Repeating Characters (Leetcode 395)
Problem Link: https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/
class Solution:
def longestSubstring(self, s: str, k: int) -> int:
n=len(s)
d={}
for i in s:
if(i in d):
d[i]+=1
else:
d[i]=1
for i in range(n):
if(d[s[i]]<k):
l=self.longestSubstring(s[:i],k)
r=self.longestSubstring(s[i+1:],k)
if(l>=r):
return l
else:
return r
else:
return n
PreviousContains Duplicate II (Leetcode 219)NextLength of the Longest Alphabetical Continuous Substring(Leetcode 2414)
Last updated