Simple Math, C++ Beats 95%
if it Helps You, Please Upvote Me..!\n# Approach\n Describe your approach to solving the problem. \nApproach very is simple,Just Count the number of the substri
# if it Helps You, Please Upvote Me..!\n# Approach\n<!-- Describe your approach to solving the problem. -->\nApproach very is simple,Just Count the number of the substring in which a particular Vowel Appear. \n\n**Formula: if Vowel Appera at ith position(0 based)**\n\n**number of substrings = i+(n-i-1)+(i(n-i-1))+1**\n\n\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long countVowels(string word) {\n        \n        long long n = word.size(),ans = 0;\n        vector<int> pos;\n        \n        for(int i = 0;i<word.size();i++)\n        {\n          if(word[i] ==\'a\' ||word[i]==\'i\' || word[i]==\'o\' || word[i]==\'e\'|| word[i]==\'u\')\n          {\n            long long left = i,right = n-i-1;\n            ans+=(left+right+left*right+1);\n          }  \n        }\n        return ans;\n    }\n};\n```\n![upvote.jpg](https://assets.leetcode.com/users/images/7bada4ae-9925-4f8a-8369-70ce1b36c5f3_1686985354.8943596.jpeg)\n
['Math', 'C++']