Loading...
Loading...
Kavya plays a word game on her phone. The game shows a long word and a number k. She may pick any k consecutive letters of the word, and she scores one point for every vowel in her pick. The vowels are a, e, i, o and u.
Print the highest score she can get.
Example 1
Input
beautiful 3
Output
3
The letters eau (positions 2 to 4) are all vowels.
Example 2
Input
rhythm 2
Output
0
There are no vowels. The letter y does not count.
Try the problem first. Open one hint at a time.
Count the vowels in the first k letters.
Moving one step right, one letter leaves and one letter joins. Change the count only for those two letters.
Compare with the best count after every step, including the very first pick.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor