FunctionRacerProblemsRace

Vowel-Heavy Windows

EasyTwo pointersPython, JavaScript, TypeScript, Java, C++

The vowels are a, e, i, o and u; every other letter is a consonant. A window is a block of exactly k consecutive letters of s. Count the windows that have strictly more vowels than consonants.

Windows at different positions count separately even if they overlap or read the same. If k is larger than the length of s there is no window and the answer is 0.

Example 1

s "aeixou"
k 3
returns 4

The windows are aei, eix, ixo and xou; every one has at least two vowels out of three.

Example 2

s "banana"
k 3
returns 2

Of ban, ana, nan and ana, only the two ana windows have two vowels against one consonant.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Two pointers problems