Reverse Vowels

String Manipulation Vowels Easy

Reverse Vowels

Write a function that takes a string as input and returns a new string where only the vowels are reversed, while all the other characters remain in their original positions.

Details

  • The vowels are: a, e, i, o, u (both lowercase and uppercase).
  • Only the positions of vowels should be changed. Consonants and non-letter characters should remain unchanged.
  • For example:
    • Input: "Hello, World!"
    • Output: "Holle, Werld!"

Note

This problem tests your string manipulation skills. Consider edge cases like strings without vowels or with only one vowel.

Optionally, as today is February 9, you can think of this as a mini-celebration of creative problem solving as, historically, many innovations occurred in February that reshaped technology and culture.