Problem · String
Error Digit Range
Learn this problemProblem statement
A faulty translator chooses one input digit and consistently replaces every occurrence with one output digit. The output must keep the same number of significant digits. The chosen input digit may be absent, which leaves the number unchanged. Return the difference between the maximum and minimum values that can be produced.
Function
findRange(num: int) → longExamples
Example 1
num = 111return = 888The maximum is 999 and the minimum is the unchanged 111.
Example 2
num = 10018return = 80088The maximum 90098 replaces 1 with 9; the minimum 10010 replaces 8 with 0.
Constraints
1 <= num <= 10^9- The first output digit cannot be zero.