C++ O(N) Time
See my latest update in repo LeetCode\n## Solution 1.\n\nIf s[i] is vowel, there are (i + 1) * (N - i) substrings that contain s[i] where i + 1 and N - i are th
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n## Solution 1.\n\nIf `s[i]` is vowel, there are `(i + 1) * (N - i)` substrings that contain `s[i]` where `i + 1` and `N - i` are the number of possible left and right end points of the substrings, respectively.\n\n```cpp\n// OJ: https://leetcode.com/contest/weekly-contest-266/problems/vowels-of-all-substrings/\n// Author: github.com/lzl124631x\n// Time: O(N)\n// Space: O(1)\nclass Solution {\n    bool isVowel(char c) {\n        return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\';\n    };\npublic:\n    long long countVowels(string s) {\n        long long N = s.size(), ans = 0;\n        for (long long i = 0; i < N; ++i) {\n            if (!isVowel(s[i])) continue;\n            ans += (i + 1) * (N - i);\n        }\n        return ans;\n    }\n};\n```
[]