---
# System prepended metadata

title: 2063\. Vowels of All Substrings

---

# 2063\. Vowels of All Substrings

```python=
class Solution:
    def countVowels(self, word: str) -> int:
        """
        A vowel wiil be counted once in every substring containing it.
        The total number of substrings using a vowel is: LHS-length * RHS length
             
        xxxx[a]yyyyy
        4321 0        You can use 0,1,2,3,4 letter in LHS
             0 12345  You can use 0,1,2,3,4,5 letter in LHS
        5 possibilities in LHS
        6 possibilities in RHS
        """
        vowels = set('aeiou')
        N = len(word)
        ans = 0
        for i,x in enumerate(word):
            if x in vowels:
                lhs_possibilities = i + 1
                rhs_possibilities = N - i
                
                ans += lhs_possibilities * rhs_possibilities
        return ans
                
```