My Java Solution || Runtime: 1 ms, faster than 100.00% of Java online submissions
\nclass Solution {\n    public int minMaxDifference(int num) {\n        String numStr = Integer.toString(num);\n\t\tint maxDigit = -1;\n\t\tfor (int i = 0; i < 
```\nclass Solution {\n    public int minMaxDifference(int num) {\n        String numStr = Integer.toString(num);\n\t\tint maxDigit = -1;\n\t\tfor (int i = 0; i < numStr.length(); i++) {\n\t\t\tchar c = numStr.charAt(i);\n\t\t\tif (c != \'9\') {\n\t\t\t\tmaxDigit = c - \'0\';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tString maxStr = numStr.replace(Character.forDigit(maxDigit, 10), \'9\');\n\t\tString minStr = "";\n\t\tint minDigit = -1;\n\t\tfor (int i = 0; i < numStr.length(); i++) {\n\t\t\tchar c = numStr.charAt(i);\n\t\t\tif (c != \'0\') {\n\t\t\t\tminDigit = c - \'0\';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tminStr = numStr.replace(Character.forDigit(minDigit, 10), \'0\');\n\t\tint maxNum = Integer.parseInt(maxStr);\n\t\tint minNum = Integer.parseInt(minStr);\n\t\treturn maxNum - minNum;\n    }\n}\n```
['Java']