n. You may swap two of its digits as many times as you like, but only when both digits are even or both are odd.
Return the largest number you can obtain this way.n=2716 → 6712
The even digits 2 and 6 sit at positions 0 and 3, the odd digits 7 and 1 at positions 1 and 2. Swapping 2 and 6 gives 6712; the odd ones are already in descending order.
n=135 → 531
All digits are odd, so they can be arranged freely: 531.
n=48 → 84
n=2716
6712
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.