# Help me in solving EZSPEAK problem

### My code

``````#include <iostream>
#include<stdlib.h>
using namespace std;

int main() {
int i,t;
cin>>t;

for(i=0; i<t; i++){
int n,j;
cin>>n;

string S[n];
cin>>S;

int c=0;

for(j=0; j<n; j++){
if(S[j]=='a' || S[j]=='e' || S[j]=='i' || S[j]=='o' || S[j]=='u'){
c=0;
continue;
}
else if(c<4){
c++;
}
else if(c==4){
cout<<"YES"<<endl;
break;
}
}
cout<<"NO"<<endl;
}
return 0;
}

``````

Problem Link: EZSPEAK Problem - CodeChef

@divyanshusinha
There is a flaw in the logic here. In the loop, checking for vowel and resetting the counter , otherwise increment the counter and break when threshold is reached.

Check counter value and print output.

NOTE: Code is in Python but logic will be same.

``````for i in range(n):
if(s[i]=='a'):  c=0
elif(s[i]=='e'): c=0
elif(s[i]=='i'): c=0
elif(s[i]=='o'): c=0
elif(s[i]=='u'): c=0
else:   c+=1

if(c==4):
break
if(c==4):
print('no')
else:
print('yes')
``````

Something like this, where we check if (c==4) and break from for loop.

Then we verify if value of c==4 or not, as it is possible that program might complete the loop without c ever reaching the value of 4.

If c==4 is true, we print NO. Otherwise, print YES.