# Help me in solving EZSPEAK problem

### My code

``````# cook your dish here
v=["a","e","i","o","u"]
count=0
t=int(input())
for i in range(t):
n=int(input())
s=input()
for k in range(n):
if(s[k]!=v):
count=count+1
if(count>=4):
print("NO")
break
else:
print("YES")
break
elif(s[k]==v):
count=0

``````

Problem Link: EZSPEAK Problem - CodeChef

@malav1115
In your code, there seems to be a few errors which i can see from a glance.

• Counter variable placement: You have taken your counter variable outside the test case loop so it is not resetting to zero for each individual test case and only keeps increasing.

• Wrongly checking vowels: You should have used in and not in to check if the letter is present in list of vowels, v.

• Printing before the string has fully been checked: You should not have put the print statement while checking the counter value, as it would keep executing each time and thus mess with the desired output.

• Breaking the loop without need: There was no need for else condition at all, you could have checked if counter has reached a particular value or not. Then you could have used break to break from checking the string if the value was reached.

``````# cook your dish here
v=['a','e','i','o','u']
for _ in range(int(input())):
n=int(input())
s=input()
c=0
for i in s:
if i in v:
c=0
else:
c+=1
if(c==4):
break
if(c==4):
print('NO')
else:
print('YES')

``````

code written in c++

``````#include<bits/stdc++.h>
using namespace std;

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

while(t--) {
int n;
cin >> n;
string s;
cin >> s;
int count = 0;
int notor_easy_abhay = 0;

for(int i = 0; i < n; i++) {
if(s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u') {
count++;
}

if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') {
count = 0;
}

if(count >= 4) {
notor_easy_abhay++;
break;
}
}

if(notor_easy_abhay != 0) {
cout << "NO" << endl;
}
else {
cout << "YES" << endl;
}
}

return 0;
}
``````
1 Like