C++ || Easy Explanation with comments ||
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nTo Minimine our Ans We need to do two things :\n1. Maximize the maximum d
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nTo Minimine our Ans We need to do two things :\n1. Maximize the maximum difference of two numbers. \n2. Minimize the minimum difference of two numbers.\n\nNow to minimize the difference of two number we can always minimze it to zero by changing one number to another number .\nTo maximize the difference of two number we have three options :\nA. Change last two number to first number .\nB. Change first two number to last number .\nC. Change first number to second number and last number to second last number .\n\n\n# Complexity\n- Time complexity: O(Log(n))\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimizeSum(vector<int>& nums) {\n        \n        int n = nums.size();\n        sort(nums.begin() , nums.end());\n        \n        //Option A\n        int op1 = nums[n-3] - nums[0];\n        //Option B\n        int op2 = nums[n-1] - nums[2];\n        //Option C\n        int op3 = nums[n-2] - nums[1];\n        \n        \n        return min(op1 , min(op2, op3));\n            \n    }\n};\n```
['Sorting', 'C++']