


The alphabets 'a', 'e', 'i', 'o', and 'u' are vowels, while all the remaining alphabets are consonants.
The first line of input contains an integer 'T' representing the number of test cases.
The first and the only line of each test case contains the string 'S'.
For each test case, return the string after reversing all its vowels.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= |S| <= 10^5
All characters of string S are lowercase alphabets only.
Where '|S|' denotes the length of string 'S'.
Time limit: 1 sec
The idea is to store all the vowels present in the string in another string while maintaining their respective order. After storing all the vowels in a string, we will reverse that string so that the order of all the vowels gets reversed. After that, we will iterate through the original string and replace all the vowels in the string in the order that they appear in the other string while keeping the consonants unchanged.
Let us try and find an approach to solve a simplified version of the problem where all the characters of the string ‘S’ are vowels. As all the characters of the string are vowels, the problem simplifies to reverse the string. Let us see an in place algorithm to reverse the string. To solve this problem, we can maintain two pointers, one at each end of the string, using which we will iterate through the string and swap the two characters that are currently being pointed by the two pointers and then move both the pointers forward to carry the next iteration. We will end iterating through the string when both the pointers cross each other. Similarly, consider the case when consonants are also present.
Now we will again maintain two pointers, one at each end of the string. Now, we will iterate through both the strings and swap the two characters pointed by the two characters only if both of them are vowels. Otherwise, we will move both the pointers ahead separately until both of them start pointing to a vowel. Again we will end iterating through the string when both the pointers cross each other.