Java simple solution | Clean Code
Code\njava\nclass Solution {\n    public int minMaxDifference(int num) {\n        char c[] = String.valueOf(num).toCharArray();\n        int idx = -1;\n        
# Code\n```java\nclass Solution {\n    public int minMaxDifference(int num) {\n        char c[] = String.valueOf(num).toCharArray();\n        int idx = -1;\n        for(int i = 0;i < c.length;i++){\n            if(c[i] != \'9\'){\n                idx = i;\n                break;\n            }\n        }\n        if(idx == -1) return num;\n        int max = Integer.parseInt(String.valueOf(num).replaceAll("" + c[idx],"9"));\n        int min = Integer.parseInt(String.valueOf(num).replaceAll("" + c[0],"0"));\n        return max - min;\n    }\n}\n```\n\n# Upvote if you like it \uD83D\uDC4D\uD83D\uDC4D
['Java']