O(N) TC - O(1) SC || 100% Beats ||  Most Efficient Approach  || C++ Solution
Intuition\nThere Is No Need Of Sorting Here , By the Observation Of Some Random Test Cases i got know that, we just need to keep track first 3 minimum elements 
# Intuition\nThere Is No Need Of Sorting Here , By the Observation Of Some Random Test Cases i got know that, we just need to keep track first 3 minimum elements and first 3 maximum elements . then apply the appropriate conditions to get the answer.\n# Approach\n**1 Condition**\nConsider the array : [1,4,5,6,7,8]\nNow the optimal solution in this case is changing \nchanging 1 , 4 to 5\nNow the array becomes [5,5,5,6,7,8].\nNow the answer is |5-5 | + | 8-5 | =3.\nif you observe carefully the answer is simply the difference between \nfirst maximum element and the third minimum element.\n**2 Condition**\nConsider the array : [8,28,42,58,75]\nNow the optimal solution in this case is changing \nchanging 8  to 42 and 75 to 42\nNow the array becomes [42,28,42,58,42].\nNow the answer is |42-42 | + |58 - 28 | =30.\nif you observe carefully the answer is simply the difference between \nsecond maximum element and the second minimum element.\n**3 Condition**\nConsider the array : [9,27,33,59,81]\nNow the optimal solution in this case is changing \nchanging  51  to 33 and 81 to 33\nNow the array becomes [9,27,33,33,33].\nNow the answer is |33-33 | + |33 - 9 | =24.\nif you observe carefully the answer is simply the difference between \nthird maximum element and the first minimum element.\n\nSO THE ANSWER LIES ON THESE THREE CONDITIONS ONLY , SO FIND FIRST 3 MINIMUM ELEMENT AND FIRST 3 MAXIMUM ELEMENTS  THEN RETURN THE RESULT.\n\n\n# Complexity\n- Time complexity:\nO(N)\n- Space complexity:\nO(1)\n# Code\n```\nclass Solution {\npublic:\n    int minimizeSum(vector<int>& nums) {\n       int min1=1e9,min2=1e9,min3=1e9,maxi1=0,maxi2=0,maxi3=0;\n       for(auto i:nums)\n       {\n           if(i<min1){  min3=min2;min2=min1;min1=i; }\n           else if(i<min2) { min3=min2, min2=i;}\n           else if(i<min3) min3=i;\n           if(i>maxi1) { maxi3=maxi2,maxi2=maxi1 ,maxi1=i;}\n           else if(i>maxi2) {maxi3=maxi2,maxi2=i;}\n           else if(i>maxi3) maxi3=i;\n       }\n      return min(maxi1-min3,min(abs(maxi2-min2),maxi3-min1));\n    }\n};\n```
['Greedy', 'C++']