PalantirOA #1
Swap Parity
简单可在线判题
You are given a digit string. You may swap two adjacent digits of the same parity (both odd or both even) any number of times. Find the largest number obtainable. Only adjacent digits can be swapped, so an odd digit can never move past an even digit, and vice versa.
输入格式
One line containing a string num consisting only of the digits 0–9, with 1≤length≤100000.
输出格式
Output the largest obtainable number as a string.
样例 1
输入:
7596801
输出:
9758601
样例 2
输入:
0082663
输出:
8662003
样例 3
输入:
0
输出:
0
题解
正在加载题解…