Count Vowel Substrings of a String - Problem
A substring is a contiguous (non-empty) sequence of characters within a string.
A vowel substring is a substring that:
- Only consists of vowels (
'a','e','i','o', and'u') - Has all five vowels present in it
Given a string word, return the number of vowel substrings in word.
Input & Output
Example 1 — Basic Case
$
Input:
word = "aeiouu"
›
Output:
2
💡 Note:
The vowel substrings with all 5 vowels are: "aeiou" (positions 0-4) and "aeiouu" (positions 0-5). Both contain all vowels a,e,i,o,u.
Example 2 — With Consonants
$
Input:
word = "unicornarihan"
›
Output:
0
💡 Note:
No substring contains all 5 vowels. The vowel-only segments are too short: "u", "i", "o", "a", "i", "a" - none have all 5 vowels.
Example 3 — Mixed Content
$
Input:
word = "cuaieuouuc"
›
Output:
7
💡 Note:
The vowel segment "uaieuous" (positions 1-7) contains all 5 vowels. Valid substrings are: "uaieuo", "uaieuou", "uaieuouu", "aieuou", "aieuouu", "ieuouu", "aieuouu" - total of 7.
Constraints
- 1 ≤ word.length ≤ 100
- word consists of lowercase English letters only
Visualization
Tap to expand
Understanding the Visualization
1
Input Analysis
String "cuaieuouuc" with vowels and consonants
2
Find Vowel Segments
Identify continuous vowel-only sections
3
Count Valid Substrings
Count substrings with all 5 unique vowels
Key Takeaway
🎯 Key Insight: Valid substrings need exactly 5 unique vowels and no consonants
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code