Reverse Vowels

String Manipulation Vowels Easy Coding Problem

Reverse Vowels

Given a string, your task is to write a function that reverses only the vowels in the string and returns the resulting string. The positions of all the other characters should remain unchanged.

Details:

  • Vowels are the characters: a, e, i, o, u (both uppercase and lowercase).
  • The function should swap the vowels while keeping the consonants and other non-alphabetic characters in their original positions.

Example:

  • Input: "hello"
  • Output: "holle"

Historical Note:

February has often been a month of reflection and change. Just as the vowels change positions while keeping the rest of the string intact, sometimes rearranging our priorities can lead to a refreshed perspective.

Implement your solution in under 45 minutes!