String Manipulation Approach | Dart Solution | Time O(n) | Space O(n)
ApproachThe solution finds the maximum possible difference through two key operations:

Minimum Number Creation:

Take first digit and replace all its occurrenc
## Approach
The solution finds the maximum possible difference through two key operations:

1. **Minimum Number Creation**:
   - Take first digit and replace all its occurrences with '0'
   - This ensures smallest possible number as changing first digit affects most significant position

2. **Maximum Number Creation**:
   - Find first non-9 digit in the number
   - Replace all occurrences of this digit with '9'
   - This guarantees largest possible number through single digit remapping

## Complexity
- **Time Complexity**: $$O(n)$$
  - Where n is number of digits
  - Single pass to find first non-9 digit
  - String replacement operations

- **Space Complexity**: $$O(n)$$
  - Storage for string representations
  - Where n is number of digits

# Code
```dart []
class Solution {
  int minMaxDifference(int num) {
    String minNum = num.toString();
    String maxNum = num.toString();
    minNum = minNum.replaceAll(minNum[0], '0');
    String char = maxNum[0];
    for (var i = 0; i < maxNum.length; i++) {
      if (maxNum[i] != '9') {
        char = maxNum[i];
        break;
      }
    }
    maxNum = maxNum.replaceAll(char, '9');
    return int.parse(maxNum) - int.parse(minNum);
  }
}

```
['Math', 'String', 'Greedy', 'Dart']