#2062
Count Vowel Substrings of a String
newbie · 290 · lc easy +20 · verified · 72.9% accepted · 1,112 likes · top 83%
Description
A vowel substring is a contiguous, non-empty sequence of characters consisting only of vowels ('a', 'e', 'i', 'o', 'u') that contains all five vowels at least once. Given word, count and return the number of such vowel substrings.
Example 1:
Input: word = "aeiouu"
Output: 2
Explanation: The vowel substrings of word are as follows (underlined):
- "aeiouu"
- "aeiouu"
Example 2:
Input: word = "unicornarihan"
Output: 0
Explanation: Not all 5 vowels are present, so there are no vowel substrings.
Example 3:
Input: word = "cuaieuouac"
Output: 7
Explanation: The vowel substrings of word are as follows (underlined):
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
- "cuaieuouac"
Code
1
2
3