Problem
You get a string s and an integer k. A substring is a part of a string with consecutive characters.
Return the largest number of vowels in a substring of s with length k. The vowels are a, e, i, o and u.
Example 1
- Input:
- s = "beautiful", k = 3
- Output:
- 3
- Explanation:
- The substring
"eau"has 3 vowels.
Example 2
- Input:
- s = "banana", k = 4
- Output:
- 2
- Explanation:
- Each substring of length 4 has 2 vowels.
Example 3
- Input:
- s = "rhythm", k = 2
- Output:
- 0
- Explanation:
shas no vowels.
Constraints
- 1 <= s.length <= 10^5
- s has only lowercase English letters.
- 1 <= k <= s.length
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Maximum Length Substring With Two Occurrences
Coding
- Maximum Number of Groups With Increasing Length
Coding
- Maximum Number of Occurrences of a Substring
Coding · Hash Table · Sliding Window · String
- All the Pairs With the Maximum Number of Common Followers
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1456. Maximum Number of Vowels in a Substring of Given Length
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source