Maths  || Observational || 12MS || Simple Formula Observation Unique Solution & Explaination
I simply Observe the Pattern by taking different size strings using pen and paper and Observe that the number of occurance of every character in a string follow
I simply Observe the Pattern by taking different size strings using pen and paper and Observe that the number of occurance of every character in a string follows a Simple pattern using Arithmetic Progression with (n-2) as its first element with d=-2 upto middle element then start decreasing using same progression (or you can say start from end with same initial element and d upto middle element) \n\n![image](https://assets.leetcode.com/users/images/0c3a40c9-bdc2-457a-925e-556f8e92adb0_1645782349.990878.png)\n\n\n```\nlong long countVowels(string word) {\n\t\tios::sync_with_stdio(false);\n        cin.tie(nullptr);\n        int n=word.length();\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                long long j=(i)<(n-i-1)?i:(n-i-1);\n                long long k=(j*(2*(n-2)+(j-1)*(-2))/2); //sum of AP\n                ans+=(n+k);  \n            }\n        }\n        return ans;\n    }\n\n```
[]