2063. Vowels of All Substrings||C++||with Explanation
Logic-\nWeight that char (at index i), Ci is contributing is given by, \n= Number of substrings containing that index char  (if Ci is vowel)\n =0 (otherwise if 
Logic-\nWeight that char (at index i), Ci is contributing is given by, \n= Number of substrings containing that index char  (if Ci is vowel)\n =0 (otherwise if char Ci is not a vowel)\n \nThe total sum of the number of vowels (\'a\', \'e\', \'i\', \'o\', and \'u\') in every substring of word will be equal to the sum of weight contributed by each character.\nSo,\n**Number of substrings containing that index i char  (if Ci is vowel)=  (no of prefix substrings+  no of suffix substrings -1)+ (no of prefix substrings * no of suffix substrings )**\nHere, \n(no of prefix substrings+  no of suffix substrings +1 )=n\n\nSo, we can say ,\n**Number of substrings containing that index i char  (if Ci is vowel)=n+ (no of prefix substrings * no of suffix substrings )**\n\n\nEg |"bcaxy"|=5\ncalculating weight contributed to sum by char a=>\n* prefix- |bc|=2, prefix strings ending with a= {ca,bca}=2\n* suffix=|xy|=2, suffix strings starting with a= {ax,axy}=2\n* {a}=1\n* sum of above 3 terms=2+2+1=5=n\n* substrings having char a in middle(having both a part of prefix substring and suffix substring=\n2*2=4\n{cax,caxy,bcax,bcaxy}\nans=n+2*2=5+2*2=9\n\n```\n long long countVowels(string word) {\n        int n=word.size();\n        long long sum=0;\n        for(int j=0;j<n;j++){\n            if(word[j]==\'a\'||word[j]==\'e\'||word[j]==\'i\'||word[j]==\'o\'||word[j]==\'u\'){\n                if(j==0||j==n-1){\n                    sum+=n;\n                }\n                else\n                sum+= n+((long long)j)*(n-j-1);\n            }\n        }\n        return sum;\n    }\n```
['C', 'C++']