3325. Count Substrings With K-Frequency Characters I Medium

@problem@discussion
#Hash Table#String#Sliding Window



1/**
2 * [3325] Count Substrings With K-Frequency Characters I
3 *
4 * Given a string s and an integer k, return the total number of <span data-keyword="substring-nonempty">substrings</span> of s where at least one character appears at least k times.
5 *  
6 * <strong class="example">Example 1:
7 * <div class="example-block">
8 * Input: <span class="example-io">s = "abacb", k = 2</span>
9 * Output: <span class="example-io">4</span>
10 * Explanation:
11 * The valid substrings are:
12 * 
13 * 	"aba" (character 'a' appears 2 times).
14 * 	"abac" (character 'a' appears 2 times).
15 * 	"abacb" (character 'a' appears 2 times).
16 * 	"bacb" (character 'b' appears 2 times).
17 * </div>
18 * <strong class="example">Example 2:
19 * <div class="example-block">
20 * Input: <span class="example-io">s = "abcde", k = 1</span>
21 * Output: <span class="example-io">15</span>
22 * Explanation:
23 * All substrings are valid because every character appears at least once.
24 * </div>
25 *  
26 * Constraints:
27 * 
28 * 	1 <= s.length <= 3000
29 * 	1 <= k <= s.length
30 * 	s consists only of lowercase English letters.
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/count-substrings-with-k-frequency-characters-i/
36// discuss: https://leetcode.com/problems/count-substrings-with-k-frequency-characters-i/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn number_of_substrings(s: String, k: i32) -> i32 {
42        0
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_3325() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.