dsa · easy

Reverse Vowels

Reverse only the vowels in s and return the new string. Consonants stay where they are. Vowels are a, e, i, o, u in either case; y is not a vowel.

Arguments

Example

s = "hello": the vowels are e then o. Swap them → "holle".

s = "education": vowels e,u,a,i,o reverse to o,i,a,u,e"odicatuen".

Constraints

1 <= s.length <= 3 * 10^5 s consists of printable ASCII letters. Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
'hello'

Expected:
holle

Example 2

Input:
'education'

Expected:
odicatuen

Open in the Dojo editor