✅C++ | ✅Intuitive Approach
Intuition\nTo get minimum score either we need to make smallest element as larget or largest element as smallest in the array.\n\n# Approach\nWe have three case
# Intuition\nTo get minimum score either we need to make smallest element as larget or largest element as smallest in the array.\n\n# Approach\nWe have three cases by which we can get minimum score\n## Case-1:\nWe can make first two elements as maximum element.\n**Example-**\n[1,4,7,8,5]\n[1,4,5,7,8] (sorted)\n[8,8,5,7,8] (applied case-1)\nScore = (8-5)-(8-8) = 3\n\n## Case-2:\nWe can make last two elements as minimum element.\n**Example-**\n[1,4,3]\n[1,3,4] (sorted)\n[1,1,1]\nScore = (1-1)-(1-1)=0\n\n## Case-3:\nWe can make 1st and last position element as 2nd minimum element or 2nd maximum element.\n**Example-**\n[58,42,8,75,28]\n[8,28,42,58,75] (sorted)\n[28,28,42,58,28]\nScore = (58-28)-(28-28)=30\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution \n{\npublic:\n    int minimizeSum(vector<int>& nums) \n    {\n        int n=nums.size();\n        sort(nums.begin(), nums.end());\n        \n        //case-1 make first two elements as maximum element \n        int high1 = nums[n-1] - nums[2]; \n        \n        //case-2 make last two elements  as minimum element\n        int high2 = nums[n-3] - nums[0];\n        \n        //case-3 make 1st and last position element as 2nd minimum element or 2nd maximum element\n        int high3 = nums[n-2] - nums[1];\n        \n        return min({high1, high2, high3});        \n    }\n};\n```\n\n# Please upvote if you like this approach
['Array', 'Math', 'Sorting', 'C++']