#K83517. Reverse Vowels in a String
Reverse Vowels in a String
Reverse Vowels in a String
Given a string s, reverse the order of the vowels while preserving the positions of all other characters. The vowels are defined as \(\{ a, e, i, o, u, A, E, I, O, U \}\). This problem requires you to implement an efficient approach to extract all vowels, reverse them, and then re-insert them into the string in their original positions.
Example: For the input hello
, the vowels e
and o
are reversed to produce holle
.
inputFormat
The input consists of a single line containing a non-empty string s with length up to 1000 characters. The string may include letters, digits, spaces, and punctuation.
outputFormat
Output the string after reversing only its vowels. The output should be printed on a single line.
## samplehello
holle