🔥✅✅ Dart Solution 📌📌 || with Explanation 👌👌
Solution
Convert the Number to a String: This allows easy manipulation of individual digits.
Generate All Possible Remappings: For each unique digit in the numb
# Solution

1. **Convert the Number to a String**: This allows easy manipulation of individual digits.
2. **Generate All Possible Remappings**: For each unique digit in the number, remap it to every possible digit (0-9).
3. **Calculate Maximum and Minimum Values**: Track the maximum and minimum values obtained from all possible remappings.
4. **Compute the Difference**: Subtract the minimum value from the maximum value to get the result.

### Time Complexity Analysis:

- **Step 1**: Converting the number to a string takes O(d)*O*(*d*), where d*d* is the number of digits in `num`.
- **Step 2**: For each unique digit in the number, we generate 10 possible remappings. If there are u*u*unique digits, this step takes O(u×10)*O*(*u*×10).
- **Step 3**: For each remapping, we generate a new number, which takes O(d)*O*(*d*) time. Since there are u×10*u*×10 remappings, this step takes O(u×10×d)*O*(*u*×10×*d*).
- **Step 4**: Computing the difference is O(1)*O*(1).

```dart
class Solution {
  int minMaxDifference(int num) {
    String numStr = num.toString();
    Set<String> uniqueDigits = numStr.split('').toSet();
    int maxVal = num;
    int minVal = num;
    for (String digit in uniqueDigits) {
        for (int newDigit = 0; newDigit <= 9; newDigit++) {
            String newNumStr = numStr.replaceAll(digit, newDigit.toString());
            int newNum = int.parse(newNumStr);
            if (newNum > maxVal) {
                maxVal = newNum;
            }
            if (newNum < minVal) {
                minVal = newNum;
            }
        }
    }
    return maxVal - minVal;
  }
}
```
['Dart']