3306. Count of Substrings Containing Every Vowel and K Consonants II Medium

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



1/**
2 * [3306] Count of Substrings Containing Every Vowel and K Consonants II
3 *
4 * You are given a string word and a non-negative integer k.
5 * Return the total number of <span data-keyword="substring-nonempty">substrings</span> of word that contain every vowel ('a', 'e', 'i', 'o', and 'u') at least once and exactly k consonants.
6 *  
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">word = "aeioqq", k = 1</span>
10 * Output: <span class="example-io">0</span>
11 * Explanation:
12 * There is no substring with every vowel.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">word = "aeiou", k = 0</span>
17 * Output: <span class="example-io">1</span>
18 * Explanation:
19 * The only substring with every vowel and zero consonants is word[0..4], which is "aeiou".
20 * </div>
21 * <strong class="example">Example 3:
22 * <div class="example-block">
23 * Input: <span class="example-io">word = "</span>ieaouqqieaouqq<span class="example-io">", k = 1</span>
24 * Output: 3
25 * Explanation:
26 * The substrings with every vowel and one consonant are:
27 * 
28 * 	word[0..5], which is "ieaouq".
29 * 	word[6..11], which is "qieaou".
30 * 	word[7..12], which is "ieaouq".
31 * </div>
32 *  
33 * Constraints:
34 * 
35 * 	5 <= word.length <= 2 * 10^5
36 * 	word consists only of lowercase English letters.
37 * 	0 <= k <= word.length - 5
38 * 
39 */
40pub struct Solution {}
41
42// problem: https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-ii/
43// discuss: https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-ii/discuss/?currentPage=1&orderBy=most_votes&query=
44
45// submission codes start here
46
47impl Solution {
48    pub fn count_of_substrings(word: String, k: i32) -> i64 {
49        
50    }
51}
52
53// submission codes end
54
55#[cfg(test)]
56mod tests {
57    use super::*;
58
59    #[test]
60    fn test_3306() {
61    }
62}
63


Back
© 2025 bowen.ge All Rights Reserved.