100 % faster
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach \nSort the Array: \nSorting helps easily find the smallest and largest ele
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach \nSort the Array: \nSorting helps easily find the smallest and largest elements, and it allows us to calculate the smallest differences between consecutive elements.\n\nPossible Changes:\nAfter sorting, consider adjusting the two smallest or two largest elements to reduce the maximum range.\nFor example, in the sorted array, try setting the smallest two values close to the next larger values or the largest two values close to the next smaller values.\n\nCalculate Scores:\nFor each possible adjustment, calculate the new high and low scores.\nTrack the minimum score across these adjustments.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int minimizeSum(int[] nums) {\n         int n = nums.length;\n        // Sort the array\n        Arrays.sort(nums);\n        \n        // Initial potential results by making changes to the smallest/largest elements\n        int option1 = nums[n - 1] - nums[2]; // Replace first two elements with the third element\n        int option2 = nums[n - 3] - nums[0]; // Replace last two elements with the third-last element\n        int option3 = nums[n - 2] - nums[1]; // Replace first and last elements with second and second-last elements\n        \n        // Minimum of the potential scores after changes\n        return Math.min(option1, Math.min(option2, option3));\n    }\n}\n```
['Java']