Easy and with O(N) time complexity.
Intuition\n Describe your first thoughts on how to solve this problem. \nMove from right to left and take the first digit which is not equal to 9.If Bob remaps 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMove from right to left and take the first digit which is not equal to 9.If Bob remaps all occurrence of this digit to 9 then he will get the maximum number. Now take the first digit of the number moving from right to left. If Bob remaps all occurrence of this digit to 0 then he will get the minimum number.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nPut the digits of the number in an array and do the above mentioned task to find the maximum and minimum number. Return their difference.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(n)\n\n\n# Code\n```java []\nclass Solution {\n    public int minMaxDifference(int num) {\n        int n = num;\n        int size = 0;\n        int j=0;\n        int firstDigit = 0;\n        while(n>0){\n            size++; \n            n=n/10;\n        }\n        int [] arr = new int[size];\n        n = num;\n        while(n>0){\n            arr[size-j-1] = n%10; \n            n=n/10;\n            j++;\n        }\n        for(int i=0;i<size;i++){\n            if(arr[i]==9){\n                continue;\n            }\n            else{\n                firstDigit = arr[i];\n                break;\n            }\n        }\n        int max = 0;\n        int min = 0;\n        for(int i=0;i<size;i++){\n            if(arr[i]==firstDigit){\n                max=max*10+9;\n            }\n            else{\n                max=max*10+arr[i];\n            }\n        }\n        firstDigit = arr[0];\n        for(int i=0;i<size;i++){\n            if(arr[i]==firstDigit){\n                 min=min*10+0;\n            }\n            else{\n                min=min*10+arr[i];\n            }\n        }\n\n        return max-min;\n    }\n}\n```
['Java']