Longest Substring with At Least K Repeating Characters
MediumStringssliding window
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given a string s and an integer k, return the length of the longest substring in which **every** character that appears does so at least k times.
If no non-empty substring qualifies, return 0.
Examples
Input: s = "aaabb", k = 3
Output: 3
"aaa" works; the b characters appear only twice.
Input: s = "ababbc", k = 2
Output: 5
In "ababb", a appears 2 times and b appears 3 times.
Constraints
- 1 <= s.length <= 10^4
- `s` consists of lowercase English letters.
- 1 <= k <= 10^5
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.