Simple C++ easy to understand solution !
\n# Code\n\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string m="";\n        string n="";\n        vector<int>ans;\n        while(n
\n# Code\n```\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string m="";\n        string n="";\n        vector<int>ans;\n        while(num>0){\n            ans.push_back(num%10);\n            num=num/10;\n}\n        reverse(ans.begin(),ans.end());\n    \n        int mc;\n        int mn;\n        //maximum\n        for(int i=0;i<ans.size();i++){\n        if(ans[i] < 9){\n            mc=ans[i];\n            break;\n}\n}\n        // min\n        \n            for(int i=0;i<ans.size();i++){\n        if(ans[i] > 0){\n            mn=ans[i];\n            break;\n}\n}\n                for(int i=0;i<ans.size();i++){\n            if(ans[i] == mn){\n                n+=to_string(0) ;\n}\n            else n+=to_string(ans[i]);\n            \n}\n        \n        \n\n        \n        for(int i=0;i<ans.size();i++){\n            if(ans[i] == mc){\n                m+=to_string(9) ;\n}\n            else m+=to_string(ans[i]);\n            \n}\n        int n1=stoi(m);\n        int n2=stoi(n);\n        \n        cout<<n1<<"   "<<n2;\n        \n        \n        return n1-n2;\n        \n        \n    }\n};\n```
['C++']