Longest Substring with At Least K Repeating Characters
Given a string `s` and an integer `k`, return the length of the longest substring of `s` such that the frequency of each character in this substring is greater than or equal to `k`.
If no such substring exists, return 0.
30:00
Longest Substring with At Least K Repeating Characters
Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k.
If no such substring exists, return 0.
Example 1:
Input: {"s":"aaabb","k":3}
Output: 3
Constraints:
1≤s.length≤104
s consists of only lowercase English letters.
1≤k≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"aaabb","k":3}
A window cannot just grow or shrink on its own here, so fix how many distinct letters it may hold (target = 1..2) and slide once per target. A window is valid when every letter in it appears at least k = 3 times.