Python3: Step Separation Approach (85.26 TC)
IntuitionThe intuition for solving this problem is based on breaking down each operation from the task description and repeating them until the required conditi
# Intuition
The intuition for solving this problem is based on breaking down each operation from the task description and repeating them until the required condition is met.

# Approach
1. Move the logic for checking if the array is non-decreasing into a separate `is_decreasing` function. $$O(n)$$
2. Move the logic for finding the adjacent pair with the minimum sum into an `adjacent_pair` function. $$O(n)$$
3. Repeat the process: while the array is not non-decreasing, replace the selected adjacent pair with their sum and increment the `result` counter that tracks the number of performed actions.

# Complexity
- Time complexity: $$O(n²)$$

- Space complexity: $$O(1)$$

# Code
```python3 []
class Solution:
    def minimumPairRemoval(self, nums: List[int]) -> int:
        def is_decreasing(arr):
            for i in range(len(arr)-1, -1, -1):
                if i != 0 and arr[i-1] > arr[i]:
                    return False
            return True

        def adjacent_pair(arr):
            min_sum = float('inf')
            min_index = float('inf')
            for i in range(len(arr)-1):
                adj_sum = arr[i] + arr[i+1]
                if adj_sum < min_sum:
                    min_sum = adj_sum
                    min_index = i
            return min_sum, min_index

        result = 0
        non_decreasing = is_decreasing(nums)
        while non_decreasing is False:
            adj_sum, adj_index = adjacent_pair(nums)
            nums[adj_index:adj_index+2] = [adj_sum]
            non_decreasing = is_decreasing(nums)
            result += 1

        return result
```

![Screen Shot 2025-04-09 at 17.54.20.png](https://assets.leetcode.com/users/images/555386b5-5fed-4ca4-99cf-259c42c90077_1744215543.65682.png)

['Array', 'Simulation', 'Python3']