[C++] Counting the contribution of each index O(n) time
Number of substrings that contain the i\'th index is (i+1)\(n-i)\nWe count the contribution of each vowel, for this we count the number of subarrays it can be a
Number of substrings that contain the i\'th index is (i+1)\\*(n-i)\nWe count the contribution of each vowel, for this we count the number of subarrays it can be a part of.\nThe subarrays which start at index [0, i] (inclusive) and the subarrays which end at index [i, n-1] (inclusive) will all contain the i\'th index.\nHence total such sub arrays will be (i+1)*(n-i)\n\n```\nclass Solution {\npublic:\n    long long countVowels(string word) {\n        long long n = word.size();\n        long long ans = 0;\n        for(int i=0; i<n; i++){\n            if(word[i]==\'a\' || word[i]==\'e\' || word[i]==\'i\' || word[i]==\'o\' || word[i]==\'u\'){\n                ans += (n-i)*(i+1);\n            }\n        }\n        return ans;\n    }\n};\n```
['C']