Question
Digit Dance

Bob uncovers a peculiar riddle in an ancient tome. He’s given a string of digits, S, of length N, and must form the smallest possible number by reordering them. The catch: he can only swap adjacent digits if one is even and the other odd. Help Bob determine the smallest number achievable under this rule.

Input
The first line of input contains a single integer N.
The next line of input contains a string of digits.
Output
Determine the smallest number achievable under this rule.
Example
Sample Input
4
0709
Sample Output
0079
Explanation
Index 2 and 3 can be swapped as 7(odd) and 0(even) are of different parity.

Online