Simplest Approach Beginer's Friendly C++
IntuitionApproachComplexity

Time complexity:
O(d)
Where d is the number of digits in the input integer num.


Space complexity:
O(d)
Where d is the number of d
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

# Complexity
- Time complexity:
O(d)
Where d is the number of digits in the input integer num.

- Space complexity:
O(d)
Where d is the number of digits in the input integer num

# Code
```cpp []
class Solution {
public:
    int minMaxDifference(int num) {
        string maxi = to_string(num);
        string mini = to_string(num);
        int x = 0;
        char st;
        while (x < maxi.length()) {
            if (maxi[x] == '9') {
                x++;
            } else {
                st = maxi[x];
                break;
            }
        }
        for (int i = 0; i < maxi.length(); i++) {
            if (maxi[i] == st) {
                maxi[i] = '9';
            }
        }
        char st2 = mini[0];
        for (int i = 0; i < mini.length(); i++) {
            if (mini[i] == st2) {
                mini[i] = '0';
            }
        }
        return abs(stoi(mini) - stoi(maxi));
    }
};
```
['C++']