Practice Vowels of All Substrings
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word. A substring is a contiguous (non-empty) sequence of characters within a string. Note: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.
Source: Vowels of All Substrings on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
word = "aba"
Output
6
# Example 2
Input
word = "abc"
Output
3
# Example 3
Input
word = "ltcd"
Output
0
Constraints
1 <= word.length <= 10^5
word consists of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Vowels of All Substrings.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.