Search⌘ K
AI Features

Solution: Reverse Vowels of a String

Explore the two pointers pattern to efficiently reverse vowels in a string. This lesson guides you through an in-place algorithm that swaps vowels without disturbing other characters, improving your problem-solving skills for coding interviews.

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:

  • 11 \leq s.length 3×105 ...