JPMorgan ChaseOA #18
Swap Parity (Data Scientist / Analytics :)
估计简单可在线判题
You may only swap two adjacent digits with the same parity, any number of times. Return the largest digit string; all digits, including zeros, must be kept. For the original 0082663 the correct result is 8662003; the original example dropped the zeros.
输入格式
One line with a digit string of length 1..100000 containing only 0..9; leading zeros are allowed.
输出格式
Output the largest digit string of the original length; leading zeros must not be removed.
样例 1
输入:
7596801
输出:
9758601
样例 2
输入:
0082663
输出:
8662003
样例 3
输入:
0214
输出:
2014
样例说明
The outputs of the three public examples are, in order: 9758601; 8662003; 2014. These answers have been checked by independent enumeration or direct simulation.