Easy C++ Solution ✔✔
Code\n\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        vector<int> v;\n        while (num>0){\n            v.push_back(num%10);\n      
## Code\n```\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        vector<int> v;\n        while (num>0){\n            v.push_back(num%10);\n            num/= 10;\n        }\n        reverse(v.begin(),v.end());\n        vector<int> miniv,maxiv;\n        for (int i=0; i<v.size(); i++){\n            if (v[i]==v[0]){\n                miniv.push_back(0);\n            }   \n            else miniv.push_back(v[i]);\n        }\n        int it=-1;\n        for (int j=0; j<v.size(); j++){\n            if (v[j]!=9){\n                it= j;\n                break;\n            }\n        }\n        for (int i=0; i<v.size(); i++){\n            if (it!= -1 && v[i]==v[it]){\n                maxiv.push_back(9);\n            }\n            else maxiv.push_back(v[i]);\n        }\n        \n        \n        int mini= 0, maxi=0;\n        for (int it=0; it<maxiv.size(); it++){\n            maxi*= 10;\n            maxi+= maxiv[it];\n        }\n        for (int it=0; it<miniv.size(); it++){\n            mini*= 10;\n            mini+= miniv[it];\n        }\n        return abs(mini-maxi);\n        \n    }\n};\n```
['Array', 'Math', 'Greedy', 'C++']