Python | 5 lines of code
Approach\nFor minimal value we always just replace first digit into zero:\nint(num.replace(num[0], "0").\n\nFor maximum value - find first non-9 digit and repla
# Approach\nFor minimal value we always just replace first digit into zero:\n`int(num.replace(num[0], "0")`.\n\nFor maximum value - find first non-9 digit and replace it into 9.\n\n\n# Complexity\n- Time complexity: $$O(1)$$ as we only interate over string with maximum 8 chars. \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minMaxDifference(self, num: int) -> int:\n        num = str(num)\n        i = 0\n        while num[i] == "9" and i < len(num)-1:\n            i += 1\n\n        return int(num.replace(num[i], "9")) - int(num.replace(num[0], "0"))\n        \n```
['Python3']