SImple CPP solution with clear explanation and comments
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nWe need to find out in 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe need to find out in how many substrings a vowel occurs. The approach is simple.\nConsider a given string "bcedru"\nSuppose I want to know in how many strings e is occuring.\nOne way to find out the number of occurences with e as the starting character and e is not the start character.\n1)e as start character: to the right of e, there are 3 character and including e, there will be 4. The length of string is 6 and the current index of e is 2. So,with e as start character, in 6-2 or n - i sub strings, where n is the length of string and i is the current index of string,e will be the starting character.\n2)e is not the starting character: From the starting index, i.e 0, to the current index of e, i.e. 2, there will 2-0 +1 substrings, or i - 0 + 1 = i +1 substrings, where e will be present but not as a starting character. \nSo, you get the frequencies where e is not the starting character and e is the starting character. Multiply them and add it to your answer.\nSimilarly, calculate for all vowels\n\n\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n   bool isVowel(char c){\n        return c==\'a\' || c==\'e\' || c==\'i\' || c==\'o\' || c==\'u\';\n    }\n        \n    long long countVowels(string word) {\n        \n        long long ans = 0;\n        int n = word.length();\n        for(int i=0; i< n;i++){\n            if(isVowel(word[i])){\n                //calculating left substring frequency\n                long long leftSubStr = i+1;\n                 //calculating right substring frequency\n                long long rightSubStr = n-i;\n                ans+=(leftSubStr * rightSubStr); \n            }\n            \n        }\n        return ans;\n    }\n};\n```
['C++']