A password-recovery tool has captured a candidate passphrase, but a faulty keylogger recorded its vowel keystrokes in reverse order while recording every consonant keystroke correctly and in its true position. To reconstruct a valid candidate, leave every consonant exactly where it already sits, and reverse the left-to-right order of just the vowel letters (a, e, i, o, u, in either case) among themselves; each vowel keeps its own original case, it only moves to a different slot in the string.
A single line containing the passphrase s.
Print the reconstructed passphrase.
s consists only of uppercase and lowercase English letters (A-Z, a-z).Example 1
Input
leetcode
Expected
leotcede
Explanation
The vowels in left-to-right order are e, e, o, e (at positions 1, 2, 5, 7). Reversed, that sequence becomes e, o, e, e. Placing them back into positions 1, 2, 5, 7 in that new order (consonants l, t, c, d untouched at positions 0, 3, 4, 6) gives `leotcede`.
Example 2
Input
AEIOUaeiou
Expected
uoieaUOIEA
Explanation
Every character here is a vowel, so the whole string is simply reversed character by character: `A,E,I,O,U,a,e,i,o,u` becomes `u,o,i,e,a,U,O,I,E,A`, giving `uoieaUOIEA`. Each letter keeps its own case; only its position flips.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →