AI Features

Solution: Reverse Vowels of a String

Let's solve the Reverse Vowels of a String problem using the Two Pointers pattern.

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\leq 3 \times 10^5 ...