You are given a string s consisting only of lowercase English letters. Count the number of contiguous substrings of s that meet both of these requirements:
'a', 'e', 'i', 'o', 'u' at least once.In other words, a valid substring must be built entirely from vowels and must include all five vowels at least once. If the same substring appears at different positions in s, each occurrence is counted separately.
Constraints:
1 <= s.length <= 10^5s are lowercase English letters (ASCII 'a' through 'z').Example 1:
s = "aeiouxaeaeiouu"
7
There are 6 distinct substrings that satisfy the conditions: "aeiou", "aeiouu", "eaeiou", "aeaeiou", "eaeiouu", and "aeaeiouu". Among these, "aeiou" occurs twice (starting at index 0 and index 8), so the total count is 7.
Example 2:
s = "aeiouxa"
1
The only valid substring is "aeiou" (indices 0–4). All other substrings either contain a consonant (like 'x') or miss at least one vowel, so the count is 1.
Example 3:
s = "bcdfg"
0
The string contains no vowels, so no substring can meet the requirements. The output is 0.
Example 1
Input: aeiouxaeaeiouu
Output: 7
Example 2
Input: aeiouxa
Output: 1