All problems

Problem 321

Reverse Vowels of a String

Easy · 10 pts · String, Two Pointers

Problem

Reverse only the vowels of a string and leave every other character where it is. The vowels are a, e, i, o and u, in both lowercase and uppercase. For example, in 'hello' the vowels e and o swap places to give 'holle'. If the string has fewer than two vowels it stays the same.

Input

A single string S made of English letters and digits (no spaces).

Output

Print S with its vowels reversed.

Constraints

1 <= |S| <= 100000

Example input

leetcode

Example output

leotcede

Explanation

The vowels of 'leetcode' are e, e, o, e (in order). Reversed they are e, o, e, e, and putting them back into the vowel positions gives 'leotcede'.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Subarrays with Product Less Than K Next: Determine if Two Strings Are Close