O(n) time, O(1) solution [C++]
Faster than 100%, O(n) time, O(1) space\n\nEvery vowel character will occur in (i+1) * (size-i) substrings, where i is the index of the vowel character in strin
**Faster than 100%, O(n) time, O(1) space**\n\nEvery vowel character will occur in **(i+1) * (size-i)** substrings, where **i** is the index of the vowel character in string.\n```\nclass Solution {\npublic:\n    bool isVowel(char ch) {\n        return ch==\'a\' or ch==\'e\' or ch==\'i\' or ch==\'o\' or ch==\'u\';\n    }\n    long long countVowels(string word) {\n        long long ans = 0;\n        for(int i=0 ; i<word.size() ; ++i)\n            if(isVowel(word[i]))\n                ans += (i+1)*(word.size()-i);\n        return ans;\n    }\n};\n```
[]