📌EASY C++ SOLUTION | EXPLAINED
\n# Approach\n Describe your approach to solving the problem. \nThe function first converts num to a string and loops over all possible pairs of digits (i, j) t
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe function first converts num to a string and loops over all possible pairs of digits (i, j) that can be used to remap a digit in num. For each pair (i, j), the function creates a new string newNumStr by replacing all occurrences of digit i with digit j. The new string is then converted back to an integer newNum, and the minimum and maximum values seen so far are updated as necessary. Finally, the function returns the difference between the maximum and minimum values.\n\n# Code\n```\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string numStr = to_string(num);\n        int n = numStr.size();\n        int minVal = num, maxVal = num;\n        for (int i = 0; i < 10; i++) {\n            for (int j = 0; j < 10; j++) {\n                string newNumStr = numStr;\n                for (int k = 0; k < n; k++) {\n                    if (newNumStr[k] - \'0\' == i) {\n                        newNumStr[k] = j + \'0\';\n                    }\n                }\n                int newNum = stoi(newNumStr);\n                if (newNum < minVal) minVal = newNum;\n            \n                if (newNum > maxVal) maxVal = newNum;\n            }\n        }\n        return maxVal - minVal;\n    }\n};\n```
['C++']