2063.cpp (388B)
1 class Solution { 2 inline static bool isVowel(const char c) { 3 return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; 4 } 5 6 public: 7 long long countVowels(const string &word) const { 8 long long n = size(word), res = 0; 9 for (int i = 0; i < n; i++) { 10 if (isVowel(word[i])) res += (i + 1) * (n - i); 11 } 12 return res; 13 } 14 };