Nobel Vowel

Noble Vowel

Given a string SS your task is to find out whether a string is Noble Vowel string or not. A Nobel Vowel string is one in which there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant nn; after this letter, there can be any letter (not only a vowel) or there can be no letter at all.

Input format

The first line contains an integer T denoting the number of test cases. Each test case consists of one string S consisting of lower case alphabets.

Output format

For each test case on a new line print YES if S is a Noble Vowel string else print NO .

Constraints:

1<=T<=10
1<=|S|<=1000

Time Limit

1 second

Example

Input

2
aeiou
cefduo

Output

YES
NO

Explanation

In the first string, every vowel is followed by another vowel or consonant. So the string is Noble Vowel. In the second string, ff is a consonant, which should be followed by a vowel but it is being followed by another consonant, so this string is not Noble Vowel.

Start from index 0 and check the current character. If the current character is not vowel(i.e. consonant) then immediately check the next character. If the next character is also a consonant then the string is not Nobel Vowel.
Here the code :-
#include <bits/stdc++.h>
using namespace std;

#define TT ll tt; cin>>tt; while(tt--)

typedef long long ll;
typedef long double ld;

bool isVowel(char x) {
    if(x=='a' || x=='e' || x=='i' || x=='o' || x=='u')
        return true;
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    TT
    {
        string s;
        cin>>s;
        bool flag = true;
        for(int i=0;i<s.size()-1; i++) {
            if(!isVowel(s[i])) {
                if(!isVowel(s[i+1]) && s[i+1] != 'n') {
                    flag = false;
                    break;
                }
            }
        }
        if(flag)
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }
    return 0;
}

Question link!

you missed a condition that there is a exception ‘n’

Corrected.

1 Like

it is not accepting!!

Provide Question Link.

can any one solve this

Noble Vowel

Given a string SS your task is to find out whether a string is Noble Vowel string or not. A Nobel Vowel string is one in which there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant nn; after this letter, there can be any letter (not only a vowel) or there can be no letter at all.

Input format

The first line contains an integer TT denoting the number of test cases. Each test case consists of one string SS consisting of lower case alphabets.

Output format

For each test case on a new line print YES if SS is a Noble Vowel string else print NO .

Constraints:

1<=T<=101<=T<=10 1<=|S|<=10001<=|S|<=1000

Time Limit

11 ​secon

Example

Input

2 aeiou cefduo

Output

YES NO

Explanation

In the first string, every vowel is followed by another vowel or consonant. So the string is Noble Vowel. In the second string, ff is a consonant, which should be followed by a vowel but it is being followed by another consonant, so this string is not Noble Vowel.