number. You may pick one digit a and one digit b and replace **every** occurrence of a in the number with b. Picking b = a is allowed and leaves the number unchanged. Leading zeros after the replacement are fine: 0020 simply means 20.
First use such a replacement to get the largest possible number, then, separately and possibly with a different replacement, the smallest one. Return the difference between them.number=4024 → 9009
Maximum: turn every 4 into 9 to get 9029. Minimum: turn every 4 into 0 to get 0020, which is 20. The spread is 9029 - 20 = 9009.
number=909 → 999
Maximum: turn 0 into 9 to get 999. Minimum: turn 9 into 0 to get 000, which is 0. The answer is 999.
number=7 → 9
number=4024
9009
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.