Reorder only the vowels in a string while keeping all consonants in their original positions.
Given a string s, sort all vowels in s in nondecreasing order while leaving every non-vowel character exactly where it is.
Vowels are a, e, i, o, u, and their uppercase variants.
Return the modified string after the vowels have been rearranged.
Only the vowels may move. All other characters must stay in the same indices they originally occupied.
s.s may contain lowercase letters, uppercase letters, and possibly other characters depending on the test setting.Treat vowels case-sensitively for ordering, but identify both lowercase and uppercase vowels as vowels.
s.1 <= s.length <= $10^{5}$Example 1
Input
s = "lEetcOde"
Output
"lEOtcede"
Explanation
The vowels are E, e, O, e. Sorted by character order, they become E, O, e, e. Putting them back into the vowel slots gives lEOtcede.
Example 2
Input
s = "leetcode"
Output
"leetcedo"
Explanation
The vowels are e, e, o. Sorted order is still e, e, o, so only their positions are rearranged accordingly.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.