C++ 0 ms
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int min_sum(const vector<int>& v, const int len) {
        int pos = 0, min_sum = v[0] + v[1];
        for(int i = 1; i < len - 1; ++i) {
            int sum = v[i] + v[i + 1];
            if(sum < min_sum) {
                min_sum = sum;
                pos = i;
            }
        }
        return pos;
    }
    
    int minimumPairRemoval(vector<int>& nums) {
        int count = 0;
        int len = size(nums);
        while(len > 1) {
            if(is_sorted(begin(nums), begin(nums) + len)) break;
            int i = min_sum(nums, len);
            nums[i] += nums[i + 1];
            rotate(begin(nums) + i + 1, begin(nums) + i + 2, begin(nums) + len);
            ++count;
            --len;
        }
        return count;
    }
};
```
['C++']