Find longest substring with ≥k repeats
Company: TikTok
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency with string-processing techniques and character frequency analysis, focusing on algorithmic skills in the Coding & Algorithms domain. It is commonly asked to assess algorithmic reasoning about constraint handling, edge cases, and efficiency, and is positioned at the practical application level rather than purely conceptual understanding.
Constraints
- s contains lowercase English letters
- 1 <= k <= len(s) for normal cases
Examples
Input: ('aaabb', 3)
Expected Output: 3
Input: ('ababbc', 2)
Expected Output: 5
Input: ('abcd', 2)
Expected Output: 0
Input: ('weitong', 2)
Expected Output: 0
Input: ('abc', 1)
Expected Output: 3
Hints
- A character whose total frequency in a segment is below k cannot be inside a valid substring crossing that character.