Dsa
Sliding Window
Medium
Max Number of Vowels in Substring
Given a string s and an integer k, return the maximum number of vowels in any contiguous substring of length k.
Input:
A string s (1 ≤ |s| ≤ 10^5) consisting of lowercase English letters.
An integer k (1 ≤ k ≤ |s|).
Output:
An integer representing the maximum number of vowels found in any substring of length k.
Example:
Input:
aeious
goodbye
3
Output:
3
Key concepts
sliding_windowsubarrayscounting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now