C++| Easy Code with Explanation | 90% Fast
Please Upvote :)\n\n\nclass Solution {\npublic:\n    long long countVowels(string word) {\n        long long res=0;\n        for(int i=0;i<word.length();i++)\n 
Please Upvote :)\n\n```\nclass Solution {\npublic:\n    long long countVowels(string word) {\n        long long res=0;\n        for(int i=0;i<word.length();i++)\n        {\n            if(vowel(word[i]))\n            {\n                long long t=word.length()-i;\n// there are i char till here soo each of them can create t substrings using this char\n                res+=i*t; \n                res+=t; // contribution to subtstrings starting from here\n            }\n        }\n        return res;\n    }\n    bool vowel(char c)\n    {\n        if(c==\'a\' || c==\'e\' || c==\'i\' || c==\'o\' || c==\'u\')\n            return true;\n        return false;\n    }\n};\n```
['C', 'C++']