Prepin
Log in

A vowel substring is defined as a substring made up exclusively of vowels ('a', 'e', 'i', 'o', and 'u') that includes all five vowels. Given a string called word, determine the total count of vowel substrings within it.

Approach / Explanation

This inquiry requires you to determine and report the number of substrings found within a specific string. This string is composed solely of vowel characters and must include all five vowels: 'a', 'e', 'i', 'o', and 'u'. To address this issue, it is important to remember that a substring represents a continuous sequence of characters within a string. For example, in the word "hello," the substrings include: "he" "ell" "llo" "hello" and so on. In this case, we are specifically focused on substrings that are made up entirely of the five vowel characters 'a', 'e', 'i', 'o', 'u', and these substrings must contain all five vowels. Here are some important points to keep in mind: First, verify whether the word contains all five vowels. If it does not, return 0, as it will lack any vowel substrings. If it does, traverse through the word to identify all vowel substrings. This can be done using a sliding-window technique, where you maintain a window of characters and slide it across the string. Maintain a counter for each vowel and increase the count whenever a vowel is found. Reset the counters whenever a non-vowel character is encountered. Keep track of the valid substrings identified, and return this total as the final result.

Suggested Answer

Take the word "aeiou" as an example: This word is made up solely of the five vowels: 'a', 'e', 'i', 'o', 'u'. Therefore, it represents one complete valid vowel substring. For this input, the function should return 1 .

Alternative Answer

Take the word "aeiobcdouaei" as an example: This word contains several substrings that feature all five vowels. Examples of such substrings include "aeiobcdou", "eiobcdoua", and "iobcdouaei". Additionally, "obcdouaei" is another valid substring. Each of these substrings contains all five vowels. As a result, the function should return 4 for this input.

Question Details

Difficulty & Category

Medium
data structures

Companies

Oracle

Product

For CandidatesFor RecruitersCompaniesBrowse JobsInterview QuestionsDeep ProfileSkill AssessmentOpportunity Matching
Prepin.ai

© 2026 Prepin LLC · Philadelphia, PA · All rights reserved.