Reverse Vowels of a String

Easy

Topics
StringTwo Pointers

Given a string s, reverse only the vowels (a e i o u, both cases) and return the result.

Example 1

Input:  s = "hello"
Output: "holle"

Example 2

Input:  s = "leetcode"
Output: "leotcede"

Constraints

  • 1 <= s.length <= 3*10^5
Run ⌘' · Submit ⌘⏎