Easy Pronunciation Codechef Solution | EZSPEAK | (100/100) FULL | Codechef July Lunchtime | AC Code

Words that contain many consecutive consonants, like “schtschurowskia“, are generally considered somewhat hard to pronounce.

We say that a word is hard to pronounce if it contains or more consonants in a row; otherwise it is easy to pronounce. For example, “apple” and “polish” are easy to pronounce, but “schtschurowskia” is hard to pronounce.

You are given a string consisting of lowercase Latin characters. Determine whether it is easy to pronounce or not based on the rule above — print YES if it is easy to pronounce and NO otherwise.

For the purposes of this problem, the vowels are the characters and the consonants are the other characters.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two lines of input.The first line of each test case contains a single integer , the length of string
  • The second line of each test case contains the string

    Output Format

    For each test case, output on a new line the answer — YES if

    is easy to pronounce, and NO otherwise.

    Each character of the output may be printed in either uppercase or lowercase. For example, the strings YES, yeS, yes, and YeS will all be treated as identical.

    Constraints

    • contains only lowercase Latin characters, i.e, the characters

    Sample Input 1

    5
    5
    apple
    15
    schtschurowskia
    6
    polish
    5
    tryst
    3
    cry
    

    Sample Output 1

    YES
    NO
    YES
    NO
    YES
    

    Explanation

    Test case

    ” doesn’t have or move consecutive consonants, which makes it easy to pronounce.

    Test case

    ” has consecutive consonants, which makes it hard to pronounce.

    Test case

    doesn’t contain or more consecutive consonants, so it’s easy to pronounce.

    Test case

    contains consecutive consonants, making it hard to pronounce.

    Test case

    doesn’t contain any vowels, but its length is less than so it’s still easy to pronounce.

    				
    					#include <bits/stdc++.h>
    using namespace std;
    
    void solve()
    {
        int n;
        string s;
        cin >> n;
        cin >> s;
        int x = 0, d = 0;
        for (auto i : s)
        {
            if (d == 4)
            {
                x = 1;
            }
            if (i == 'a' i == 'e' i == 'i' i = 'o' i == 'u')
            {
                d = 0;
            }
            else
            {
                d++;
            }
        }
        if (x == 0)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    
    int main()
    {
        int t;
        cin >> t;
        // in(t);
        while (t--)
        {
            solve();
        }
        return 0;
    }
    				
    			

    0 Comments

    Leave a Reply

    Avatar placeholder

    Your email address will not be published.