A text-to-speech preview plays a snippet of exactly k characters from a caption text. Snippets with more vowels sound smoother, so the preview picks the one with the most.
Write mostVowels(text, k) that returns the largest number of vowels (a, e, i, o, u, lowercase only) in any k consecutive characters of text. k is never more than text.length.
Input: text = "hello world", k = 3 Output: 1
No 3 characters in a row hold more than one vowel.
Input: text = "queue", k = 4 Output: 4
ueue has four vowels.
1 <= k <= text.length <= 100000text contains lowercase letters and spaces.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #129 Most Vowels in a Snippet. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.