Java Declarative Approach
Code\njava []\nclass Solution {\n  public int minMaxDifference(int num) {\n    var n = String.valueOf(num);\n    var maxChar = n\n      .chars()\n      .mapToOb
# Code\n```java []\nclass Solution {\n  public int minMaxDifference(int num) {\n    var n = String.valueOf(num);\n    var maxChar = n\n      .chars()\n      .mapToObj(it -> (char) it)\n      .filter(it -> it != \'9\')\n      .map(it -> String.valueOf(it))\n      .findFirst()\n      .orElse("0");\n    var minChar = n\n      .chars()\n      .mapToObj(it -> (char) it)\n      .filter(it -> it != \'0\')\n      .map(it -> String.valueOf(it))\n      .findFirst()\n      .orElse("9");\n    var max = n.replaceAll(maxChar, "9");\n    var min = n.replaceAll(minChar, "0");\n    return Integer.parseInt(max) - Integer.parseInt(min);\n  }\n}\n```
['Java']