Question bank › Sliding Window
Dsa Sliding Window Hard

Max Consonants in Sliding Window

Given a string `sentence`, find the maximum number of consonants that can be found in any substring of length `k`. A consonant is any letter that is not a vowel (a, e, i, o, u). If the length of `sentence` is less than `k`, return -1. Input Format: The first line is an integer `k` (the length of the substring). The second line is the string `sentence`. Output Format: Output a single integer representing the maximum number of consonants in any substring of length `k`. Example: Input: 3 hello world Output: 2

Key concepts

sliding_windowstringcounting

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.