Count of Substrings Containing Every Vowel and K Consonants I - Problem
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.
Input & Output
Example 1 — Basic Case
$
Input:
word = "aeioqq", k = 1
›
Output:
0
💡 Note:
No substring contains all vowels (a,e,i,o,u) and exactly 1 consonant. Missing vowel 'u'.
Example 2 — Valid Case
$
Input:
word = "aeiou", k = 0
›
Output:
1
💡 Note:
The substring "aeiou" contains all vowels and exactly 0 consonants.
Example 3 — Multiple Valid
$
Input:
word = "aeiouc", k = 1
›
Output:
1
💡 Note:
The substring "aeiouc" contains all vowels (a,e,i,o,u) and exactly 1 consonant (c).
Constraints
- 1 ≤ word.length ≤ 1000
- 0 ≤ k ≤ word.length
- word consists only of lowercase English letters
Visualization
Tap to expand
Understanding the Visualization
1
Input
String word and integer k
2
Process
Find all substrings with all vowels and exactly k consonants
3
Output
Count of valid substrings
Key Takeaway
🎯 Key Insight: Use sliding window to efficiently track character counts and avoid redundant substring generation
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code