Reverse Vowels

String Manipulation Vowels Easy

Reverse Vowels in a String

Write a function that takes a string and returns a new string with the positions of the vowels reversed. The consonants and non-letter characters should remain in their original positions.

Example

  • Input: "hello world"
  • Output: "holle wlrld"

Constraints

  • Preserve the case of characters.
  • Only reverse the vowels (a, e, i, o, u in both uppercase and lowercase).

Note

On April 10, many cultures celebrate events that remind us to look at things from a different angle. In this spirit, challenge your perspective on simple string manipulation by reversing only the vowels.