Question bank › Sliding Window
Dsa Sliding Window Hard

Largest Sum of Consonants in Substring of Vowels

Given a string `s`, find the maximum sum of the ASCII values of consonants in all substrings that contain only vowels. Return the length of the substring that gives this maximum sum. If no such substring exists, return 0. Input: - A single line containing the string `s`. Output: - An integer representing the length of the substring that yields the maximum consonants sum. Example: Input: aeibcdouoa Output: 4 In this case, the substring 'aeib' has consonants 'b' and 'c', with a total ASCII value of 198. The length is 4, which is the maximum for any vowel-only substring.

Key concepts

sliding_windowarraysconditionals

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.