start
and end
, to 0.totalVowels
to 0 to keep track of the distinct vowels in the current window.result
to 0 to keep the count of valid substrings.end
pointer.
a. If the current character is a vowel, increment its count and increment totalVowels
if this is the first occurrence of the vowel in the window.
b. While totalVowels
is 5 (all vowels are present), try to shrink the window from the start
to find the smallest window containing all vowels and update result
.
c. If a non-vowel character is encountered, reset the counts and totalVowels
, and move start
to end + 1
.result
.