RubrikOA #11
Doing Smart Work
Estimated MediumJudge-ready
Topics (AI-labelled)Two PointersStrings
You may swap adjacent digits of different parity any number of times; find the smallest number you can obtain, with leading zeros allowed.
Input
The first line contains t; then t lines of digit strings follow. Added by this site: t≤10000, total length ≤200000.
Output
For each test case, output the smallest digit string on its own line.
Example 1
Input:
1
4321
Output:
3142
Example 2
Input:
3
97531
02468
9081726354
Output:
97531
02468
0826491735
Example 3
Input:
2
1203
5550
Output:
1203
0555
Editorial
Loading solution…