JavaScript solution
Intuition\nThe answer will be in one of 3 cases. We set Max and second Max elements to third Max. We set Min and second Min elements to third Min element. We se
# Intuition\nThe answer will be in one of 3 cases. We set Max and second Max elements to third Max. We set Min and second Min elements to third Min element. We set Max to second Max and Min to second Min.\n\n# Approach\nTo simplify the code we sort the array. The answer will be the following Math.min(nums[end-2]-nums[0], nums[end-1]-nums[1], nums[end]-nums[2])\n\n# Complexity\n- Time complexity:\nO(N*log(N))\n\n- Space complexity:\nO(1)\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minimizeSum = function(nums) { \n    let arr = nums.sort((a,b) => a - b);\n    let end = nums.length -1;\n    \n    return Math.min(nums[end-2]-nums[0], nums[end-1]-nums[1], nums[end]-nums[2]);\n};\n```
['JavaScript']