Show problems as
Classic problem #2062EasyHash TableString

Count Vowel Substrings of a String

Real-world version: All-Five Vowel Windows
Tracked in this browser only
Read Count Vowel Substrings of a String on LeetCode(opens in a new tab)

The statement here is our own: the same inputs, outputs and technique.

A speech-training tool scans a lowercase transcription text for stretches that drill all five vowel sounds.

A vowel window is a non-empty contiguous stretch of text that contains no consonant and in which each of a, e, i, o and u appears at least once. Two windows count separately when they begin or end at different positions, even if they spell the same thing.

Return the number of vowel windows in text.

Examples

Example 1

Input
text = "aeioua"
Output
3

The windows are "aeiou" starting at 0, "aeioua" starting at 0 and "eioua" starting at 1.

Example 2

Input
text = "oiuae"
Output
1

The whole transcription is the only window; every shorter stretch is missing a vowel.

Example 3

Input
text = "aeiouzaeiou"
Output
2

The five characters before the z form one window and the five after it form another; no window can span the z.

Example 4

Input
text = "banana"
Output
0

No stretch of this transcription contains all five vowels.

Constraints

  • 1 <= text.length <= 100
  • text consists of lowercase English letters only.

The signature

The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.

Python
def count_vowel_substrings(text: str) -> int:
Java
public int countVowelSubstrings(String text)