Simple Java O(n)
\nclass Solution {\n    public long countVowels(String word) {\n        long res = 0, prev = 0;\n        for(int i=0; i<word.length(); i++) {\n            char 
```\nclass Solution {\n    public long countVowels(String word) {\n        long res = 0, prev = 0;\n        for(int i=0; i<word.length(); i++) {\n            char c = word.charAt(i);\n            if(c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\')\n                prev += i + 1;\n            res += prev;\n        }\n        \n        return res;\n    }\n}\n```
['Dynamic Programming', 'Java']