digits of decimal digits. At most once, you may swap two adjacent digits, but only if both are even or both are odd (for example, 3 and 7 or 0 and 8 qualify, while 4 and 5 do not).
Return the lexicographically smallest string you can get this way. Making no swap at all is allowed.digits="6285" → '2685'
6 and 2 are both even, so they may be swapped, and "2685" is smaller than the original.
digits="7429" → '7249'
The pairs 7/4 and 2/9 mix parities. 4 and 2 are both even, and swapping them gives the smaller "7249".
digits="1357" → '1357'
All digits are odd, but they already increase, so any swap would only make the string larger.
digits consists of digits onlydigits="6285"
'2685'
Run checks the first 3 tests in your browser. Submit checks all 127 tests on the server, hidden ones included.