Problem · String

Error Digit Range

Learn this problem
MediumAtlassian logoAtlassianINTERNFULLTIMEOA

Problem 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) → long

Examples

Example 1

num = 111return = 888

The maximum is 999 and the minimum is the unchanged 111.

Example 2

num = 10018return = 80088

The 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.

More Atlassian problems

drafts saved locally
public long findRange(int num) {
  // Write your code here.
}
num111
expected888
checking account