15MS 🏆 ||🌟JAVA ☕
Code


# Code
```java []
class Solution {
    public long countVowels(String word) {
        long res = 0,sz = word.length(); // Focus on return type

        for (int i = 0; i < sz; i++)
            if ("aeiou".indexOf(word.charAt(i)) != -1)
                res += (i + 1) * (sz - i); // Magical line

        return res;        
    }
}
```
![f69ffdba-12f7-4f5b-8950-e7d3bd77c52a_1733768002.4687448.png](https://assets.leetcode.com/users/images/108509bf-dfd5-4e18-8ae2-664ca54ea1fc_1740045549.6060677.png)

['Java']