Search⌘ K
AI Features

Solution: Reverse Vowels of a String

Solution: Reverse Vowels of a String asks you to return a string with only its vowels reversed, while every consonant and other character remains in its original position, handling both cases.

Statement

Given a string s, reverse only the vowels in the string and return the resulting string.

The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appear in both lowercase and uppercase, potentially more than once.

Constraints:

  • 1≤1 \leq s.length ≤3×105 ...