Simple Greedy Solution
Replace all first non 9 digit with 9 to get maximum number\n- Replace all first non 0 digit with 0 to get minimum number\n- And just return answer\n# Code\n\ncl
- Replace all first non 9 digit with 9 to get maximum number\n- Replace all first non 0 digit with 0 to get minimum number\n- And just return answer\n# Code\n```\nclass Solution(object):\n    def minMaxDifference(self, num):\n        min_, max_ = str(num), str(num)\n        for ch in min_:\n            if ch != \'0\':\n                min_ = min_.replace(ch, \'0\')\n                break\n        for ch in max_:\n            if ch != \'9\':\n                max_ = max_.replace(ch, \'9\')\n                break\n        return int(max_) - int(min_)\n```\n**UpVote**, if you like it **:)**
['String']