............................................................................
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int minMaxDifference(int num) {
        string s =to_string(num), large = to_string(num), small = to_string(num);
        char dl = -1, ds = -1;
        for(int i = 0; i < s.size(); ++i){
            if(dl == -1 && s[i] != '9'){
                dl = s[i];
                large[i] = '9';
            }else {
                large[i] = (s[i] == dl)?'9': s[i];
            }
            
            if(ds == -1 && s[i] != '0'){
                ds = s[i];
                small[i] = '0';
            }else{
                small[i] = (s[i] == ds)?'0':s[i];
            }
        }
        return stoi(large) - stoi(small);
    }
};
```
['Math', 'C++']