🚀 Best Python Solution | Beginner Friendly | Clean Code + Explanation
IntuitionThe task is to transform the array into a non-decreasing array by repeatedly removing two adjacent elements and replacing them with their sum. The key
# Intuition
The task is to transform the array into a **non-decreasing array** by repeatedly removing two adjacent elements and replacing them with their sum. The key observation is:

To minimize the number of operations, we should always merge the pair with the smallest sum to reduce the chance of creating larger decreasing values.

# 🧭 Approach
- Check if the array is non-decreasing. If yes, return 0.

- Otherwise, find the adjacent pair `(i, i+1)` with the minimum sum.

- Replace both elements with their sum, effectively reducing the array size by 1.

- Count the operation.

Repeat until the array is sorted in non-decreasing order.
# ⏱️ Complexity
**Time Complexity:**
    - **Worst case:** `(On*2)`

- Each operation takes `O(n)` to find the minimum sum pair, and there can be up to `O(n)` operations.

**Space Complexity:** `O(n)`
- Due to slicing and copying the array in each operation.


# Code
```python3 []
class Solution:
    def minimumPairRemoval(self, nums: List[int]) -> int:
        def is_non_decreasing(arr):
            return all(arr[i] <= arr[i+1] for i in range(len(arr) - 1))

        operations = 0
        
        while not is_non_decreasing(nums):
            min_sum = float('inf')
            min_index = -1
            
            for i in range(len(nums) - 1):
                pair_sum = nums[i] + nums[i+1]
                if pair_sum < min_sum:
                    min_sum = pair_sum
                    min_index = i
            
            # Replace the pair with their sum
            new_num = nums[min_index] + nums[min_index + 1]
            nums = nums[:min_index] + [new_num] + nums[min_index + 2:]
            operations += 1

        return operations
```
['Python3']