Files
cpp-flashcards/org/study_deck_02/dsa/sliding-window/3306-count-of-substrings-containing-every-vowel-and-k-consonants-ii.org
T
tomatocream 1dec88aaf2 feat: populate note files with problem descriptions and code stubs
Add populate-notes.mjs that fetches problem descriptions and
Python/C++ code stubs from LeetCode's GraphQL API. Populated
all 197 NeetCode 150 note files with:
- Problem description (examples, constraints)
- Python code stub (function signature)
- C++ code stub (function signature + includes)

API responses cached in leetcode/.cache/leetcode/ for instant re-runs.
2026-06-01 17:22:07 +08:00

1.5 KiB

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

You are given a string word and a non-negative integer k.

Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', and 'u') at least once and exactly k consonants.

Example 1:

Input: word = "aeioqq", k = 1

Output: 0

Explanation:

There is no substring with every vowel.

Example 2:

Input: word = "aeiou", k = 0

Output: 1

Explanation:

The only substring with every vowel and zero consonants is word[0..4], which is "aeiou".

Example 3:

Input: word = "ieaouqqieaouqq", k = 1

Output: 3

Explanation:

The substrings with every vowel and one consonant are:

  • word[0..5], which is "ieaouq".
  • word[6..11], which is "qieaou".
  • word[7..12], which is "ieaouq".

Constraints:

  • 5 <= word.length <= 2 * 10^{5}
  • word consists only of lowercase English letters.
  • 0 <= k <= word.length - 5

TODO Approach

Write your approach here.

TODO Python

class Solution:
    def countOfSubstrings(self, word: str, k: int) -> int:

TODO C++

class Solution {
public:
    long long countOfSubstrings(string word, int k) {
        
    }
};