Count the Number of Vowel Strings in Range - Problem
You are given a 0-indexed array of string words and two integers left and right.
A string is called a vowel string if it starts with a vowel character and ends with a vowel character where vowel characters are 'a', 'e', 'i', 'o', and 'u'.
Return the number of vowel strings words[i] where i belongs to the inclusive range [left, right].
Input & Output
Example 1 — Basic Range
$
Input:
words = ["are","amy","u"], left = 0, right = 2
›
Output:
2
💡 Note:
"are" starts with 'a' and ends with 'e' (both vowels). "u" starts and ends with 'u' (vowel). "amy" starts with 'a' but ends with 'y' (not a vowel).
Example 2 — Partial Range
$
Input:
words = ["hey","aeo","mu","ooo","artro"], left = 1, right = 4
›
Output:
3
💡 Note:
In range [1,4]: "aeo" (a-o), "ooo" (o-o), "artro" (a-o) are vowel strings. "mu" (m-u) is not because it starts with 'm'.
Example 3 — Single Element
$
Input:
words = ["a","b","c"], left = 1, right = 1
›
Output:
0
💡 Note:
Only checking words[1] = "b", which starts and ends with 'b' (not a vowel).
Constraints
- 1 ≤ words.length ≤ 1000
- 1 ≤ words[i].length ≤ 10
- words[i] consists of only lowercase English letters
- 0 ≤ left ≤ right < words.length
Visualization
Tap to expand
Understanding the Visualization
1
Input Array
Array of strings with left and right boundaries
2
Range Check
Examine strings only within [left, right] range
3
Count Result
Count strings that start and end with vowels
Key Takeaway
🎯 Key Insight: Only check strings within the given range and verify both first and last characters are vowels
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code