Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Maximum Number of Vowels in a Substring of Given Length (medium)
On this page

Problem Statement

Examples

Try it yourself

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
  • Expected Output: 5
  • Justification: The substring "aeixoyu" contains three vowels ('a', 'e', 'i', 'o', 'u').

Constraints:

  • 1 <= s.length <= 10<sup>5</sup>
  • s consists of lowercase English letters.
  • 1 <= k <= s.length

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

Problem Statement

Examples

Try it yourself