You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# [2566.Maximum Difference by Remapping a Digit][title]
2
+
3
+
## Description
4
+
5
+
You are given an integer `num`. You know that Bob will sneakily **remap** one of the `10` possible digits (`0` to `9`) to another digit.
6
+
7
+
Return the difference between the maximum and minimum values Bob can make by remapping **exactly one** digit in `num`.
8
+
9
+
**Notes**:
10
+
11
+
- When Bob remaps a digit d1 to another digit d2, Bob replaces all occurrences of `d1` in `num` with `d2`.
12
+
- Bob can remap a digit to itself, in which case `num` does not change.
13
+
- Bob can remap different digits for obtaining minimum and maximum values respectively.
14
+
- The resulting number after remapping can contain leading zeroes.
15
+
16
+
**Example 1:**
17
+
18
+
```
19
+
Input: num = 11891
20
+
Output: 99009
21
+
Explanation:
22
+
To achieve the maximum value, Bob can remap the digit 1 to the digit 9 to yield 99899.
23
+
To achieve the minimum value, Bob can remap the digit 1 to the digit 0, yielding 890.
24
+
The difference between these two numbers is 99009.
25
+
```
26
+
27
+
**Example 2:**
28
+
29
+
```
30
+
Input: num = 90
31
+
Output: 99
32
+
Explanation:
33
+
The maximum value that can be returned by the function is 99 (if 0 is replaced by 9) and the minimum value that can be returned by the function is 0 (if 9 is replaced by 0).
0 commit comments