Skip to content

Practice Reverse Vowels of a String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#345
LeetCode Problem

Reverse Vowels of a String

Problem Statement

Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.

Source: Reverse Vowels of a String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "IceCreAm"
Output
"AceCreIm"

# Example 2

Input
s = "leetcode"
Output
"leotcede"

Constraints

1 <= s.length <= 3 * 10^5
s consist of printable ASCII characters.

Related LeetCode Problems

Practice more problems similar to Reverse Vowels of a String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.