c++(0ms)
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 maxi = to_string(num), mini = to_string(num);
    
    for(int i = 0; i != maxi.size(); ++i)
      if(maxi[i] != '9'){
        char d = maxi[i];
        for(int j = i; j != maxi.size(); ++j)
          if(maxi[j] == d) maxi[j] = '9';
        break;
      }

    char d = mini[0];
    for(int j = 0; j != mini.size(); ++j)
      if(mini[j] == d) mini[j] = '0';

    return stoi(maxi) - stoi(mini);       
  }
};
```
['C++']