← 返回 bytedance 的题目列表Longest Substring with At Least K Repeating Characters
类型:online_judge
Given a string s and an integer k, find the length of the longest substring such that every character in the substring appears at least k times.
Input:
s is a string consisting of lowercase letters only.
k is an integer such that 1 <= k <= len(s).
Output:
Return an integer representing the length of the longest substring satisfying the conditions.
Example:
Input: s = "aaabb", k = 3
Output: 3
Explanation: The longest substring is "aaa", as 'a' appears 3 times.
Input: s = "ababbc", k = 2
Output: 5
Explanation: The longest substring is "ababb" or "babab", where 'a' and 'b' both appear 2 or more times.
Example
Input
aaabb
3
Output
3