395. Longest Substring with At Least K Repeating Characters
Medium
5.2K
422

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.

 

Example 1:

Input: s = "aaabb", k = 3
Output: 3
Explanation: The longest substring is "aaa", as 'a' is repeated 3 times.

Example 2:

Input: s = "ababbc", k = 2
Output: 5
Explanation: The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times.

 

Constraints:

  • 1 <= s.length <= 104
  • s consists of only lowercase English letters.
  • 1 <= k <= 105
Accepted
185.9K
Submissions
415.3K
Acceptance Rate
44.8%

Seen this question in a real interview before?
1/4
Yes
No

Discussion (0)

Related Topics
Copyright ©️ 2023 LeetCode All rights reserved