Longest Substring with At Least K Repeating Characters
A medium-tier problem at 45% community acceptance, tagged with Hash Table, String, Divide and Conquer. Reported in interviews at Baidu and 2 others.
Longest Substring with At Least K Repeating Characters sits at 45% acceptance, which means half the people who see it on the OA blank or timeout. Baidu, Yandex, and TikTok have all asked it. The trap is obvious: you think sliding window will work, then realize the constraints don't let you. Most candidates waste 20 minutes chasing that dead end. If this problem hits your live assessment and you haven't drilled the divide-and-conquer approach, StealthCoder surfaces a working solution in seconds while the proctor sees nothing.
Companies that ask "Longest Substring with At Least K Repeating Characters"
Longest Substring with At Least K Repeating Characters is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe trick is that greedy sliding window fails here because you can't monotonically grow a valid window when characters must hit a frequency threshold. Instead, divide and conquer: pick a character that appears fewer than K times, use it as a splitter, and recursively solve the left and right substrings. This flips the problem into a base case you can actually solve. The Hash Table step counts frequencies, and each recursive call narrows the search space. Most candidates either waste time on broken sliding window logic or miss that the splitter character can never be part of the answer. When you hit the pattern, it's fast. If you don't, you're stuck. StealthCoder is the hedge for the moment you realize your first approach is a dead end.
Pattern tags
You know the problem.
Make sure you actually pass it.
Longest Substring with At Least K Repeating Characters recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Longest Substring with At Least K Repeating Characters interview FAQ
Is sliding window actually broken for this problem?+
Yes. Sliding window works when validity is monotonic: once a window is invalid, shrinking always keeps it invalid. Here, shrinking a window can break the frequency constraint in ways that don't recover. You need divide and conquer, not greedy expansion.
Why is acceptance only 45% if this is a medium?+
Candidates underestimate the trick. The obvious approach (sliding window) seems right but fails silently or times out. You have to recognize that division by splitter characters is the only clean solution, and that requires pattern recognition, not just implementation speed.
What's the real time complexity?+
Divide and conquer with memoization is O(n) in the best case but O(n^2) worst case if you pick bad splitters. The key insight is that each recursive call eliminates at least one character from the valid set, bounding total work. It's not about raw speed, it's about correctness.
Do I need to know divide and conquer beforehand to solve this?+
Not formally, but you need to recognize that the problem itself suggests the strategy: invalid characters become natural division points. If you've seen tree recursion or QuickSelect, the pattern transfers. Otherwise, you'll reinvent it under pressure or get stuck.
Is this still asked at TikTok, Baidu, and Yandex?+
Yes, all three have reported it. At 45% acceptance, companies know it's a good filter. If you're prepping for those shops, this is a must-drill. It's the kind of problem that separates prepared candidates from ones who freeze on the first false start.
Want the actual problem statement? View "Longest Substring with At Least K Repeating Characters" on LeetCode →