Maximum Vowels in a Fixed-Length Substring
At Inmobi, optimizing content delivery and user engagement is paramount. Imagine we're analyzing short text snippets, like ad headlines or search queries, to predict their potential impact. A simple yet effective heuristic could be the 'vowel density' within a focused segment. This problem asks you to identify the most 'vowel-rich' segment of a fixed length, which could inform content scoring or A/B testing strategies.
Given a string s consisting of lowercase English letters and an integer k, your task is to find the maximum number of vowel letters in any substring of s that has a length of k.
s: A string containing only lowercase English letters.k: An integer representing the exact length of the substrings to consider.k.s will only contain lowercase English letters.k will always be positive and less than or equal to the length of s.Examples
Example 1
Input:
s = "aeiou", k = 2
Output:
2
Note:
Substrings of length 2 are "ae", "ei", "io", "ou". All of them contain 2 vowels. The maximum is 2.
Example 2
Input:
s = "leetcode", k = 3
Output:
2
Note:
Substrings of length 3: "lee" (2 vowels), "eet" (2 vowels), "etc" (1 vowel), "tco" (1 vowel), "cod" (1 vowel), "ode" (2 vowels). The maximum is 2.
Example 3
Input:
s = "rhythm", k = 4
Output:
0
Note:
Substrings of length 4: "rhy" (0 vowels), "hyth" (0 vowels), "ythm" (0 vowels). The maximum is 0.
Constraints
1 <= s.length <= 10^51 <= k <= s.lengths consists of only lowercase English letters.Loading editor...