C++ || Easy approach
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(nlogn)\n\n- Space complexity:O(n)\n\n# Code\n\nclass Solution {\npublic:\n    int min
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:$$O(nlogn)$$\n\n- Space complexity:$$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int minimizeSum(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        // if(nums.size()==3){return 0;}\n        // vector<int>v=nums;\n        // int mini=*min_element(nums.begin(), nums.end()), k=2;\n        // while(k--){\n        //     int maxi=*max_element(nums.begin(), nums.end());\n        //     for(int i=0; i<nums.size(); i++){\n        //         if(nums[i]==maxi){nums[i]=mini;}\n        //     }\n        // }\n        // int n1=*min_element(nums.begin(), nums.end()), n2=*max_element(nums.begin(), nums.end());\n        // int k1=2, maxi1=*max_element(v.begin(), v.end());\n        // cout<<maxi1<<endl;\n        // while(k1--){\n        //     int mini1=*min_element(v.begin(), v.end());\n        //     for(int i=0; i<v.size(); i++){\n        //         if(v[i]==mini1){v[i]=maxi1;}\n        //     }\n        // }\n        // int nn1=*min_element(v.begin(), v.end()), nn2=*max_element(v.begin(), v.end());\n        // cout<<nn2-nn1<<" "<<n2-n1<<endl;\n        return min({nums[nums.size()-1]-nums[0], nums[nums.size()-2]-nums[1], nums[nums.size()-1]-nums[2], nums[nums.size()-3]-nums[0]});\n    }\n};\n```
['C++']