SIMPLE || C++ || EASY TO UNDERSTAND
Code\n\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        vector<int> v2,v1;\n        while(num){\n            v1.push_back(num%10);\n    
# Code\n```\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        vector<int> v2,v1;\n        while(num){\n            v1.push_back(num%10);\n            num /= 10;\n        }\n        reverse(v1.begin(),v1.end());\n        v2 = v1;\n        int x = 0, y = 0,a=v1[0],b=-1;\n        for(int i = 0; i < v1.size(); i++){\n            if(b==-1&&v1[i]!=9)b = v1[i];\n            if(v1[i]==b)v1[i] = 9;\n            if(v2[i]==a)v2[i] = 0;\n            x = x*10+v1[i];\n            y = y*10+v2[i];\n        }\n        // cout<<x<<" "<<y;\n        return x-y;\n    }\n};\n```
['Math', 'Greedy', 'C++']