### Ticker

6/recent/ticker-posts

# Vowel Recognition | Hackerearth practice problem solution

## Problem:-

{a,e,i,o,u,A,E,I,O,U}
Natural Language Understanding is the subdomain of Natural Language Processing where people used to design AI based applications have ability to understand the human languages. HashInclude Speech Processing team has a project named Virtual Assistant. For this project they appointed you as a data engineer (who has good knowledge of creating clean datasets by writing efficient code). As a data engineer your first task is to make vowel recognition dataset. In this task you have to find the presence of vowels in all possible substrings of the given string. For each given string you have to print the total number of vowels.

Input
First line contains an integer Tdenoting the number of test cases.
Each of the next lines contains a string, string contains both lower case and upper case .
Output
Print the vowel sum
Answer for each test case should be printed in a new line.
Input Constraints
1<=T<=10
1<=|S|<=100000

SAMPLE INPUT

```1
baceb
```
SAMPLE OUTPUT

```16
```
Explanation
First line is number of input string, In given example, string is "baceb" so the substrings will be like -"b, ba, bac, bace, a, ac, ace, aceb, c, ce, ceb, e, eb, baceb" now the number of vowels in each substring will be 0, 1, 1, 2, 1, 1, 2, 2, 0, 1, 1, 1, 1, 2  and the total number will be sum of all presence which is 16.
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

## solution:-

#include<stdio.h>
#include<string.h>
int main()
{
int t;
long int sum=0,l;
char s;
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
l=strlen(s);
for(int i=0;s[i];i++)
{
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'
||s[i]=='u'||s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O'||s[i]=='U')
sum=sum+(i+1)*(l-i);

}
printf("%ld\n",sum);
sum=0;
}
return 0;
}

Recommended post:-

Hackerearth Problems:-

Data structure:-

Key points:-

## 1. 2. 