Algorithm · Rubrik · Medium
You have a long integer containing n digits (the integer may have leading zeros). You can repeatedly apply the following operation, as many times as you want (including zero times): Swap two adjacent digits if the two digits have different parity. Parity is different when the two digits leave different remainders upon division by 2. Determine the smallest possible number you can form by applying the operation any number of times. The final number may have leading zeros.…
Checking your access…