Simple digits track
Intuition
Track the highest digit which not equal 9 (change to 9 to get max);
Change all digits which equal to highest digit to 0 to get min;
ApproachComplexity
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
1. Track the highest digit which not equal 9 (change to 9 to get max);
2. Change all digits which equal to highest digit to 0 to get min;
# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```csharp []
public class Solution {
    public int MinMaxDifference(int num) {
        int[] digits = new int[num.ToString().Length];
        int idx = digits.Length, cur = num;
        for(int i = digits.Length-1; i >= 0; i--)
        {
            digits[i] = cur%10;
            cur/=10;

            if(digits[i] != 9)
                idx = i;
        }

        if(idx == digits.Length)
            return num;

        int maxV = 0, minV = 0;
        for(int i = 0; i < digits.Length; i++)
        {
            maxV *= 10;
            minV *= 10;
            int curMax = digits[i] == digits[idx] ? 9 : digits[i];
            int curMin = digits[i] == digits[0] ? 0 : digits[i];
            maxV += curMax;
            minV += curMin;
        }

        return maxV-minV;
    }
}
```
['C#']