Math | Simple solution with 100% beaten
IntuitionTo minimize the score after modifying two elements, we must consider the difference between the largest and smallest values, as well as their "neighbor
# Intuition
To minimize the score after modifying two elements, we must consider the difference between the largest and smallest values, as well as their "neighbors." The strategy involves identifying possible modifications to the smallest and largest values. By removing two elements, we can minimize the score by either:

- Removing the two smallest elements.
- Removing the two largest elements.
- Removing one smallest and one largest element.

# Approach
Identify Extreme Values: We first need to find the three smallest and three largest numbers from the array. This will allow us to consider the best candidates for modification without sorting the entire array.

# Complexity
- Time complexity: O(n)

- Space complexity: O(1)

# Code
```cpp []
class Solution {
public:
    int minimizeSum(vector<int>& nums) {
        if (nums.size() == 3)
            return 0;

        vector<int> smallest(3, INT_MAX), largest(3, INT_MIN);

        for (int num : nums) {
            if (num < smallest[0]) {
                smallest[2] = smallest[1];
                smallest[1] = smallest[0];
                smallest[0] = num;
            } else if (num < smallest[1]) {
                smallest[2] = smallest[1];
                smallest[1] = num;
            } else if (num < smallest[2]) {
                smallest[2] = num;
            }
            if (num > largest[0]) {
                largest[2] = largest[1];
                largest[1] = largest[0];
                largest[0] = num;
            } else if (num > largest[1]) {
                largest[2] = largest[1];
                largest[1] = num;
            } else if (num > largest[2]) {
                largest[2] = num;
            }
        }

        int option1 = largest[0] - smallest[2]; // Remove the two smallest elements
        int option2 = largest[2] - smallest[0]; // Remove the two largest elements
        int option3 = largest[1] - smallest[1]; // Remove the smallest and the largest element


        return min({option1, option2, option3});
    }
};

```
['C++']