All problems
0392EasyHash TableString

All-Five Vowel Windows

Tracked in this browser only
Write code

Trains the technique from

LeetCode 2062Count Vowel Substrings of a String

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

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 is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

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