BEATS 100% IN C++
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string s=to_string(num);\n        string s1=s,s2=s;\n        int i=0
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string s=to_string(num);\n        string s1=s,s2=s;\n        int i=0;\n        for(;i<s1.size();i++) if(s1[i]!=\'9\') break;\n        if(i==s1.size()) return num;\n        char c=s1[i]; // to replace 9s with 0\n        i=0;\n        for(;i<s1.size();i++) if(s1[i]!=\'0\') break;\n        char c1=s1[i];// to replace most significant digit with 0\n        for(int i=0;i<s1.size();i++){\n            if(s1[i]==c) s1[i]=\'9\';\n            if(s2[i]==c1){\n                s2[i]=\'0\';\n            }\n        }\n        return (stoi(s1)-stoi(s2));\n        \n    }\n};\n```
['C++']