Leetcode 395 : Longest Substring with At Least K Repeating Characters (Python 3)
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times.
Approach - We will split our string when we find if a character is less than k, for splitting we use two variables i and j in the last while loop as you can see, we keep a SET of characters whose count is less than k. When we find a character whose count is smaller than the value of k then we split from the last valid character till before this invalid character(whose value is less) . We use recursion to fulfill our mission.
|
|