✅✔️100% Beat || Easy Solution using String || Greedy ✈️✈️✈️✈️✈️
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minMaxDifference(int num) {\n        string s = to_string(num);\n        string s1 = s, s2 = s;\n        char ch1 = s[0], ch2 = s[0];\n        for(int i=0; i<s.length(); i++){\n            if(s[i] != \'9\'){\n                ch1 = s[i];\n                break;\n            }\n        }\n        for(int i=0; i<s.length(); i++){\n            if(s[i] != \'0\'){\n                ch2 = s[i];\n                break;\n            }\n        }\n        for(int i=0; i<s.length(); i++){\n            if(s1[i] == ch1) s1[i] = \'9\';\n            if(s2[i] == ch2) s2[i] = \'0\';\n        }\n        return stoi(s1) - stoi(s2);\n    }\n};\n```
['String', 'Greedy', 'C++']