2566. Maximum Difference by Remapping a, Time complexity: O(N), Space complexity: O(N)
IntuitionApproachComplexity
Time complexity: O(N)

Space complexity: O(N)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minMaxDifference(self, num):
        num_str = str(num)

        digits = [int(d) for d in list(num_str)]
        len_digits = len(digits)

        first_non_nine_digit = digits[0]
        i = 0
        while (i < len_digits):
            if (digits[i] != 9):
                first_non_nine_digit = digits[i]
                break
            i += 1

        first_non_zero_digit = digits[0]
        i = 0
        while (i < len_digits):
            if (digits[i] != 0):
                first_non_zero_digit = digits[i]
                break
            i += 1

        max_num = int(''.join(['9' if d == first_non_nine_digit else str(d) for d in digits]))
        min_num = int(''.join(['0' if d == first_non_zero_digit else str(d) for d in digits]))
        
        return max_num - min_num
```
['Python3']