0ms 100% (Quad)
Keep enumerating until sorting is done.
Remember to find the minimum sum for the entire current array.Time complexity is quadratic.Code

Keep enumerating until sorting is done.
Remember to find the minimum sum for the entire current array.

Time complexity is quadratic.

# Code
```cpp []
class Solution {
    int find_min_sum(const std::vector<int>& nums) {
        int min_sum = std::numeric_limits<int>::max();
        int min_start = 0;
        for (int j = 0; j < nums.size() - 1; ++j) {
            const int sum = nums[j] + nums[j + 1];
            if (sum < min_sum) {
                min_sum = nums[j] + nums[j + 1];
                min_start = j;
            }
        }
        return min_start;
    }

public:
    int minimumPairRemoval(vector<int>& nums) {
        int operations = 0;
        bool done = false;
        while (!done) {
            done = true;
            for (int i = 1; i < nums.size(); ++i) {
                if (nums[i] < nums[i - 1]) {
                    done = false;
                    ++operations;
                    // Replace two elements with sum.
                    const int merge_idx = find_min_sum(nums);
                    nums[merge_idx] = nums[merge_idx] + nums[merge_idx + 1];
                    nums.erase(nums.begin() + merge_idx + 1);
                    break;
                }
            }
        }

        return operations;
    }
};
```
['C++']