Beats 90%  Java/Kotlin simple solution with explanation !
IntuitionTo get the max num we have to change the first digit that is non equal to 9;To get minimum we've to change the first digit to 0ApproachI made a functio
# Intuition
To get the max num we have to change the first digit that is non equal to 9;

To get minimum we've to change the first digit to 0

# Approach
I made a function that you input number and a digit you want to change by and execeuted it when my number = num and to get max digit = 9 and to get minimum digit = 0

At the end I took the difference btw them !

# Complexity
- Time complexity: O(n)

# Code
```java []
class Solution {
    public int minMaxDifference(int num) {
        return remapping(num,'9') - remapping(num,'0');
    }

    public int remapping(int num, char c){
        String b = String.valueOf(num);
        char ch = ' ';
        for(int i = 0; i < b.length(); i++){
            // System.out.println(b.charAt(i));
            if(b.charAt(i) != c){
                ch = b.charAt(i);
                break;
            }
        }
        
        StringBuilder sb = new StringBuilder();
        if(ch != ' '){
            for(int i = 0; i < b.length(); i++){
               if(b.charAt(i) != ch){
                   sb.append(b.charAt(i));
                }   else sb.append(c);
            }
        }else return Integer.valueOf(b);
        return Integer.valueOf(sb.toString());
    }
}
```
``` Kotlin []
class Solution {
    fun minMaxDifference(num: Int): Int {
        return remapping(num,'9') - remapping(num,'0')
    }

    fun remapping(num: Int, c: Char): Int {
    val b = num.toString()
    var ch = ' '
    for (i in 0 until b.length) {
        // System.out.println(b.charAt(i));
        if (b[i] != c) {
            ch = b[i]
            break
        }
    }

    val sb = StringBuilder()
    if (ch != ' ') {
        for (i in 0 until b.length) {
            if (b[i] != ch) {
                sb.append(b[i])
            } else sb.append(c)
        }
    } else return b.toInt()
    return sb.toString().toInt()
}
}
```
['Java', 'Kotlin']