Posts

Showing posts from April, 2016

Consonant Reversal solution

Ritika gives  N N  strings to Semona and asks her to perform a  consonant reversal  on each string  S S  such that the indexed positions of its vowels ( a a ,  e e  ,  i i ,  o o , and  u u ) are unchanged but all the consonants are reversed. This means that each vowel must be at the same exact index before and after the reversal. Because the value of  N N  is very large, Semona wants your help accomplishing this with code! Given  N N  strings, reverse and print each string such that the positions of its vowels remain unchanged but all its consonants are reversed. Input Format The first line contains an integer,  N N , the number of strings. Each of the  N N  subsequent lines contains a string,  S S , to be reversed. Constraints 1 ≤ N ≤ 1000 1 ≤ N ≤ 1000 1 ≤ | S i | ≤ 2000 1 ≤ | S i | ≤ 2000 , where  0 ≤ i < N 0 ≤ i < N Each string contains lowercase letters. Output Format For each string  S S  received as input, print the consonant reversal of  S