Skip to main content
LeetCode 1456, Medium. Topics: String, Sliding Window. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 16 parametrized pytest cases, and a playground notebook:

Problem

Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k. Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

Examples

Explanation: The substring “iii” contains 3 vowel letters.
Explanation: Any substring of length 2 contains 2 vowels.
Explanation: “lee”, “eet” and “ode” contain 2 vowels.

Constraints

  • 1 <= s.length <= 10^5
  • s consists of lowercase English letters.
  • 1 <= k <= s.length

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026