Vowels of All Substrings
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.
Example 1
Input
word = "aba"Output
6All possible substrings are "a", "ab", "aba", "b", "ba", and "a"; their vowel counts sum to 6.
Example 2
Input
word = "abc"Output
3All possible substrings are "a", "ab", "abc", "b", "bc", and "c"; their vowel counts sum to 3.
Constraints
- 1 <= word.length <= 10^5
- word consists of lowercase English letters.