Easiest C++ Solution (5 line code) - Very Easy
Intuition\nThere can only be 3 cases, either \n- Change the first 2 elements\n- We change the last 2 elements\n- We change the 1st and the last element\n\n# App
# Intuition\nThere can only be 3 cases, either \n- Change the first 2 elements\n- We change the last 2 elements\n- We change the 1st and the last element\n\n# Approach\nWe sort the given array, then we can calculate all the 3 cases just by considering the difference between the mentioned values.\nAlso, we don\'t need a seperate calculation for \'low\', since we will always replace the choosen values with the same values.\n\n# Complexity\n- Time complexity:\nO(n*log(n))\n\n- Space complexity:\nO(1)\n\n# Code\n```\nint minimizeSum(vector<int>& v) {\n        int ans=INT_MAX;\n        int n=v.size();\n        sort(v.begin(),v.end());\n        ans=min(ans,v[n-1]-v[2]);\n        ans=min(ans,v[n-3]-v[0]);\n        ans=min(ans,v[n-2]-v[1]);\n        return ans;\n    }\n```
['C++']