Sorting approach | Java solution | Clean Code
Intuition\nIf we make two elements equal then value of low will be 0. Hence we can utilize both the two operations in minimizing the value of high\n\n# Approach
# Intuition\nIf we make two elements equal then value of `low` will be `0`. Hence we can utilize both the two operations in minimizing the value of `high`\n\n# Approach\n- Sort the array in acending order\n- We can minimize the value of `high` using any of the following three operations:\n    1. If we make `nums[0] = nums[n - 1]` & `nums[1] = nums[n - 1]` then `ans` will be `nums[n - 1] - nums[2]`\n    2. If we make `nums[n - 1] = nums[0]` & `nums[n - 2] = nums[0]` then `ans` will be `nums[n - 3] - nums[0]`\n    3. If we make `nums[0] = nums[1]` & `nums[n - 1] = nums[n - 2]` then `ans` will be `nums[n - 2] - nums[1]`\n\n- Take **minimum** of above three answers\n\n# Complexity\n- Time complexity: $O(n * logn)$\n\n- Space complexity: $O(1)$\n\n# Code\n```\nclass Solution {\n    public int minimizeSum(int[] nums) {\n        Arrays.sort(nums);\n        int n = nums.length;\n        int ans = Math.min(nums[n - 1] - nums[2],nums[n - 3] - nums[0]);\n        ans = Math.min(ans,nums[n - 2] - nums[1]);\n        return ans;\n    }\n}\n```\n\n# Upvote if you like it \uD83D\uDC4D\uD83D\uDC4D
['Sorting', 'Java']