Remap to 0 or 9
We remap each i ([0..9]) to 0 or 9 to get minimum and maximum possible value. \n\nC++\ncpp\nint minMaxDifference(int num) {\n    int min_v = num, max_v = num;\n
We remap each `i` ([0..9]) to `0` or `9` to get minimum and maximum possible value. \n\n**C++**\n```cpp\nint minMaxDifference(int num) {\n    int min_v = num, max_v = num;\n    for (int i = 0; i < 10; ++i) {\n        int lo = 0, hi = 0, mul = 1;\n        for (int n = num; n; n /= 10) {\n            bool replace = n % 10 == i;\n            lo += (replace ? 0 : n % 10) * mul;\n            hi += (replace ? 9 : n % 10) * mul;\n            mul *= 10;\n        }\n        min_v = min(min_v, lo);\n        max_v = max(max_v, hi);\n    }\n    return max_v - min_v;\n}\n```
['C']