Skip to content

Practice Longest Substring with At Least K Repeating Characters

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#395
LeetCode Problem

Longest Substring with At Least K Repeating Characters

Problem Statement

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. if no such substring exists, return 0.

Source: Longest Substring with At Least K Repeating Characters on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "aaabb", k = 3
Output
3

# Example 2

Input
s = "ababbc", k = 2
Output
5

Constraints

1 <= s.length <= 10^4
s consists of only lowercase English letters.
1 <= k <= 10^5

Related LeetCode Problems

Practice more problems similar to Longest Substring with At Least K Repeating Characters.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.