AAAAAAAAAAAAAAAAAAAAAAAA
Code

# Code
```kotlin []
class Solution {
    fun minMaxDifference(num: Int): Int {
        val str = num.toString()

        val littleIndex = str.indexOfFirst { it.code - '0'.code > 0 }
        val largeIndex = str.indexOfFirst { it.code - '0'.code < 9 }
        if(largeIndex == -1) return num
        
        val little = str.replace(str[littleIndex], '0').toInt()
        val large = str.replace(str[largeIndex], '9').toInt()
        return large - little
    }
}
```
['Kotlin']