2063. Vowels of All Substrings (Medium) - TengnanYao/daily_leetcode GitHub Wiki

class Solution:
    def countVowels(self, word: str) -> int:
        result = 0
        for i, c in enumerate(word):
            if c in "aeiou":
                result += (i + 1) * (len(word) - i)
        return result