Given a string str. Your task is to write a program that takes string str as input and rearrange characters of the given string such that the vowels and consonants occupy alternate position and the string so formed should be lexicographically (alphabetically) smallest.
If string can not be rearranged in desired way, print “-1” (without quotes).
Input : mango Output : gamon It could be arranged in other ways too, like manog, etc., but gamon is lexicographically smallest.
First line of the input contains an integer T, denoting the number of test cases. Then T test case follows. First line of each test case contains an integer N, denoting the size of the string. Next line contains the string str.
For each test print the rearranged string on the new line.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.