Please answer a optimized way

how to find the total no. of times the vowels are occuring in all substring of a string

ex->coding
count=22

my code->

Efficient Approach: The idea is to use a prefix sum array-based technique where we store the occurrences of each character in all the substrings concatenated.

  • For the first character,

no. of occurrences = no. of substrings starting with the first character = N.

  • For each of the following characters, we store the

no. of substrings starting with that character + the number of substrings formed by the previous characters containing this character the number of substrings formed by the previous characters only.

you can see Reference Code if needed

if you have any doubt in any step you can ask

this is making space overflow

send me link of your code

i think it is working fine

where you got space overflow

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.