✅C++ Easy and simple solution O(1) space.
Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F\n\n# 
***Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F***\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string temp1=to_string(num),temp2=temp1;\n       \n        char change=\'-\';\n        for(int i=0;i<temp1.length();i++){\n            if(temp1[i]!=\'9\' && change==\'-\'){\n                change=temp1[i];\n                temp1[i]=\'9\';\n            }else if(temp1[i]==change){\n                temp1[i]=\'9\';\n            }\n        }\n         num=stoi(temp1);\n        change=\'-\';\n   \n        for(int i=0;i<temp2.length();i++){\n            \n            if(temp2[i]!=\'0\' && change==\'-\'){\n               \n                     change=temp2[i];\n               \n                     temp2[i]=\'0\';\n       \n            }else if(temp2[i]==change){\n                temp2[i]=\'0\';\n            }\n          \n        }\n        \n        int num2=stoi(temp2);\n        cout<<num2<<endl;\n        return num-num2;\n       \n   \n    }\n};\n\n\n```\n***Guy\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that it motivate\'s me to create more better post like this \u270D\uFE0F***
['C++']