Skip to content

Practice Sort Vowels in 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.

Medium#2785
LeetCode Problem

Sort Vowels in a String

Problem Statement

Return s with only its vowels reordered into nondecreasing ASCII order across the vowel positions. Keep every consonant in its original position. Vowels are a, e, i, o, u in either case; uppercase vowels precede lowercase vowels under ASCII.

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

Examples

# Example 1

Input
s = "lEetcOde"
Output
"lEOtcede"

# Example 2

Input
s = "lYmpH"
Output
"lYmpH"

Constraints

1 <= s.length <= 10^5
s consists only of letters of the English alphabet in uppercase and lowercase.

Related LeetCode Problems

Practice more problems similar to Sort Vowels in a String.

Review your practice with PhantomCodeAI

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