leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2063.cpp (388B)
0 class Solution {
1 inline static bool isVowel(const char c) {
2 return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
3 }
5 public:
6 long long countVowels(const string &word) const {
7 long long n = size(word), res = 0;
8 for (int i = 0; i < n; i++) {
9 if (isVowel(word[i])) res += (i + 1) * (n - i);
10 }
11 return res;
12 }
13 };