Simple java code 1 ms beats 94 %
\n# Complexity\n- \n\n\n# Code\n\nclass Solution {\n    public int minMaxDifference(int num) {\n        char c = \' \';\n        String s = ""+num;\n        for
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/4165e7b4-ba74-40b0-9b51-829b9e487221_1705455835.5409734.png)\n\n# Code\n```\nclass Solution {\n    public int minMaxDifference(int num) {\n        char c = \' \';\n        String s = ""+num;\n        for (int i = 0; i < s.length(); i++) {\n            if (s.charAt(i) != \'9\') {\n                c = s.charAt(i);\n                break;\n            }\n        }\n        char x = s.charAt(0); // replacing\n        s = s.replace(c, \'9\');\n        String s1 = ""+num;\n        s1 = s1.replace(x, \'0\');\n\n        int n1 = Integer.parseInt(s);\n        int n2 = Integer.parseInt(s1);\n        return n1 - n2;\n    }\n}\n```
['Java']