Simple Approach O(N) -- calculating No of vowels in all substrings  using prefix sum in O(N)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nfirst we store no of vowels in string  till index i in v[i].\nthen calcul
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nfirst we store no of vowels in string  till index i in v[i].\nthen calculating current ans =prev ans + no of vowels in new substrings generated by adding w[i] char using i*v[i]-pre_sum\nif this char is also vowel then add into ans and reduce pre_sum by 1 \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long countVowels(string w) {\n      long long ans=0;\n      int n=w.size();\n      vector<int>v(n);\n      unordered_set<int>s;\n      s.insert(\'a\');\n s.insert(\'e\');\n  s.insert(\'i\');\n   s.insert(\'o\');\n    s.insert(\'u\');\n    if(s.find(w[0])!=s.end())v[0]=1;\n    else v[0]=0;\nfor(int i=1;i<n;i++)\n{  v[i]=v[i-1];\nif(s.find(w[i])!=s.end())v[i]++;\n}\n\n    long long  prf_sum=0;\n\nfor(int i=0;i<n;i++){\n    ans+=i*(1LL)*v[i]-prf_sum;\n    prf_sum+=v[i];\n    if(s.find(w[i])!=s.end()){\n    prf_sum--;\n    ans++;\n    }\n}\n    return ans;\n    }\n};\n```
['C++']