Back to course home
0% completed
Vote For New Content
Solution: Maximum Number of Vowels in a Substring of Given Length
Problem Statement
Given a string s and an integer k, return the highest number of vowels in any substring of s that is exactly k characters long. Vowels in English are 'a', 'e', 'i', 'o', and 'u'.
Examples
Example 1:
- Input: 
s = "azerdii",k = 4 - Expected Output: 
2 - Justification: The substring "rdii" has two vowels ('i', 'i').
 
Example 2:
- Input: 
s = "abcde",k = 2 - Expected Output: 
1 - Justification: The substring "ab" contains one vowel ('a').
 
Example 3:
- Input: 
s = "zaeixoyuxyz",k = 7 
.....
.....
.....
Like the course? Get enrolled and start learning!