word. Consider all of its non-empty substrings (contiguous pieces), each pair of start and end positions separately, even if two pieces happen to read the same. Count the vowels (a, e, i, o, u) in each substring and return the total over all substrings.
The answer can be very large, and enumerating every substring of a long string is too slow.word='oak' → 7
The substrings are o, oa, oak, a, ak, k, with 1 + 2 + 2 + 1 + 1 + 0 = 7 vowels in total.
word='xyz' → 0
No substring contains a vowel.
word='banana' → 28
word consists of lowercase English lettersword='oak'
7
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.