#K79817. Sort Vowels and Consonants
Sort Vowels and Consonants
Sort Vowels and Consonants
You are given a string s
consisting of lowercase English letters. Your task is to rearrange the string so that all vowels appear before all consonants while preserving the relative order of vowels as well as consonants.
In other words, if s = s_1s_2\ldots s_n
, let \(V\) be the sequence of vowels in s
(in the same order) and \(C\) be the sequence of consonants in s
(in the same order). Then, the output should be the string V + " " + C
, where a single space separates the two parts.
Note: The vowels are defined as \(\{a,e,i,o,u\}\). If there are no vowels, output a space followed by the consonants. Similarly, if there are no consonants, output the vowels followed by a space.
Examples:
- Input:
example
→ Output:eae xmpl
- Input:
computer
→ Output:oue cmptr
- Input:
hello
→ Output:eo hll
inputFormat
The input consists of a single line containing a non-empty string s
of lowercase English letters.
outputFormat
Output a single line string where all the vowels of s
come first (preserving original order), followed by a single space, and then all the consonants (also preserving original order).
example
eae xmpl