Separation of Concerns Beats 96%
IntuitionWe basically want to simulate the process demanded by the problem. First we make the module that will let us work on the problem:
check if the current
# Intuition
We basically want to simulate the process demanded by the problem. First we make the module that will let us work on the problem:
- check if the current array is valid
- merge minimum sum
- put them together

# Approach
The idea is to repeatedly find and merge the pair of adjacent elements that have the smallest sum. This is a greedy approach where we assume merging the smallest-sum pair will bring us closer to a sorted array (non-decreasing order). 

1. **is_valid**: Checks if the list is non-decreasing.
2. **aggregate**: Finds the adjacent pair with the smallest sum and merges them by replacing the left element with the sum and removing the right one.
3. We repeat this process until the array is sorted, and count how many merges were needed.

# Complexity
- Time complexity:  
  $$O(n^2)$$ in the worst case.  
  Each `aggregate` call takes $$O(n)$$ time to find and merge the smallest pair. In the worst case, you may do up to $$n - 1$$ merges.

- Space complexity:  
  $$O(n)$$  
  Each merge creates a new list (due to list comprehension), so at each step you're using additional space proportional to the size of the list.


# Code
```python3 []
class Solution:
    def minimumPairRemoval(self, nums: List[int]) -> int:
        def is_valid(nums):
            return all(nums[i - 1] <= nums[i] for i in range(1,len(nums)))
        
        def aggregate(nums):
            min_sum = float('inf')
            anchor = 0
            for i in range(1, len(nums)):
                if nums[i] + nums[i - 1] < min_sum:
                    min_sum = nums[i] + nums[i - 1]
                    anchor = i
            
            ans = [x for i, x in enumerate(nums) if i != anchor]
            ans[anchor - 1] = min_sum
            return ans

        tries = 0
        while not is_valid(nums):
            nums = aggregate(nums)
            tries += 1
        return tries

```
['Python3']