Vowel Anxiety CodeChef Solution


Vowel Anxiety solution codechef

Vowel Anxiety CodeChef Solution

His teacher gave him the following problem to improve his vowel-identification skills:

There is a string SS of length NN consisting of lowercase English letters only. Utkarsh has to start from the first letter of the string.
Each time he encounters a vowel (i.e. a character from the set {a,e,i,o,u}{a,e,i,o,u}) he has to reverse the entire substring that came before the vowel.

Utkarsh needs help verifying his answer. Can you print the final string after performing all the operations for him?

Input Format

  • First line will contain¬†TT, number of test cases. Then¬†TT¬†test cases follow.
  • The first line of each test case contains¬†NN, the length of the string.
  • The second line contains¬†SS, the string itself.

Output Format

For each test case, output in a single line the final string after traversing SS from left to right and performing the necessary reversals.

Vowel Anxiety CodeChef Solution

  • 1‚ȧT‚ȧ1041‚ȧT‚ȧ104
  • 1‚ȧN‚ȧ1061‚ȧN‚ȧ106
  • Sum of¬†NN¬†over all test cases does not exceed¬†106106.

Sample Input 1 


Sample Output 1 


Vowel Anxiety CodeChef Solution

Test case 11: The first letter is a vowel, but there is no substring before it to reverse, so we leave it as it is. Next, we reverse abcd and the string becomes dcbaefghij. Next we reach the vowel i and reverse dcbaefgh to get the string hgfeabcdij.

Test case 22: Initially, we reverse bc and the string becomes cbadage. Next we reach the vowel a and reverse cbad to get the string dabcage. Finally we reach the vowel e and reverse dabcag to get the string gacbade.

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

One thought on “Vowel Anxiety CodeChef Solution

Leave a Reply

Your email address will not be published.