395. Longest Substring with At Least K Repeating Characters Medium

@problem@discussion
#Hash Table#String#Divide and Conquer#Sliding Window



1/**
2 * [395] Longest Substring with At Least K Repeating Characters
3 *
4 * 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.
5 *  
6 * Example 1:
7 * 
8 * Input: s = "aaabb", k = 3
9 * Output: 3
10 * Explanation: The longest substring is "aaa", as 'a' is repeated 3 times.
11 * 
12 * Example 2:
13 * 
14 * Input: s = "ababbc", k = 2
15 * Output: 5
16 * Explanation: The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times.
17 * 
18 *  
19 * Constraints:
20 * 
21 * 	1 <= s.length <= 10^4
22 * 	s consists of only lowercase English letters.
23 * 	1 <= k <= 10^5
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/
29// discuss: https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn longest_substring(s: String, k: i32) -> i32 {
35        0
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_395() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.