Interview Questions/Coding/Vowel Echo Score

Vowel Echo Score

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Vowel Echo Score

A voice note is analyzed by charging every substring for the vowels it contains. The vowels are a, e, i, o, and u. Each occurrence of a vowel contributes once to every substring that includes that occurrence. The goal is to compute the total vowel charge over all contiguous substrings of the note. Consonants do not add charge, but they can still be part of substrings that include vowels elsewhere. Input Format: You are given a lowercase string note. Output Format: Return the total number of vowel occurrences counted across all substrings.

Examples

Example 1
Input:
note = "aba"
Output:
6

Explanation: Vowel contributions are a@0:3, a@2:3. Their sum is 6, so the output is 6.

Approach hint

Count substrings that include a fixed position.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp