Greedy Minimum Sum Approach | Dart Solution | Time O(n³) | Space O(1)
ApproachThis solution uses a greedy strategy to merge pairs until the array becomes sorted:

Sorting Check:

Use a helper function _isSorted to verify if the ar
## Approach
This solution uses a greedy strategy to merge pairs until the array becomes sorted:

1. **Sorting Check**:
   - Use a helper function `_isSorted` to verify if the array is already sorted

2. **Greedy Pair Selection**:
   - While the array isn't sorted:
     - Find the adjacent pair with the smallest sum
     - Replace this pair with a single element (their sum)
     - Increment the operation counter

3. **Termination**:
   - Continue until the array becomes sorted
   - Return the number of operations performed

This approach merges elements that likely create inversions, gradually transforming the array into a sorted sequence.

---

## Complexity
- **Time Complexity**: $$O(n^3)$$
  - Each iteration checks if sorted $$O(n)$$ and finds minimum sum pair $$O(n)$$
  - Could require up to $$O(n)$$ iterations in worst case

- **Space Complexity**: $$O(1)$$
  - Modifies the input array in-place
  - Uses constant extra space regardless of input size

---

# Code
```dart []
class Solution {
  int minimumPairRemoval(List<int> nums) {
    int removeOperationCounter = 0;
    bool _isSorted(List<int> nums) {
      for (var i = 0; i < nums.length - 1; i++) {
        if (nums[i] > nums[i + 1]) return false;
      }
      return true;
    }
    while (!_isSorted(nums)) {
      int minSumPos = 0;
      int minSumValue = 1000000;
      for (var i = 0; i < nums.length - 1; i++) {
        if (nums[i] + nums[i + 1] < minSumValue) {
          minSumValue = nums[i] + nums[i + 1];
          minSumPos = i;
        }
      }
      nums.replaceRange(minSumPos, minSumPos + 2, [
        nums[minSumPos] + nums[minSumPos + 1],
      ]);
      
      removeOperationCounter++;
    }
    return removeOperationCounter;
  }
}

```
['Array', 'Greedy', 'Sorting', 'Dart']