2063. Vowels of All Substrings | C++ | Contribution Problem
Every element s[i] appears in two types of subarrays:\n1. In subarrays beginning with s[i]. There are \n    (n - i) such subsets.\n2. In (n - i) * i subarrays w
Every element s[i] appears in two types of subarrays:\n1. In subarrays beginning with s[i]. There are \n    `(n - i)` such subsets.\n2. In `(n - i) * i` subarrays where this element is not\n    first element.\n\nThus, total appearance of each vowel at index `i`=  `(n - i) * (i + 1)`\n\n```\nclass Solution {\npublic:\n    long long countVowels(string s) {\n        unordered_set<char> vowels{\'a\', \'e\', \'i\', \'o\', \'u\'};\n        long long ans = 0, n = s.size();\n        for(int i = 0; i < n; i++){\n            if(vowels.count(s[i])) ans += (n - i) * (i + 1);\n        }\n        return ans;\n    }\n};\n```
['Greedy']