Uhh... find k first min elements and k first max elements
Intuition\n Describe your first thoughts on how to solve this problem. \nAnother tricky problem when reading requirement, but turns into a simple problem if you
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAnother tricky problem when reading requirement, but turns into a simple problem if you translate + rephrase it properly :)\n\nHere I need to find min-range and max-range after change k numbers. Notice that I could change to any number -> I could always get min-range == 0.\n\nNow I need to minimize the max-range. Here, if I generalize to k numbers --> I need to find the min pair range between the first k min number and first k max number (min[0] and max[k] -> min[k] and max[0])\n\nThe most optimized approach to find first k min number and first k max number is properly using a heap -> nlogk. However, a sorting solution of nlogn is also okay for me.\n\nIn this problem, since n == 2 only -> We could achieve a 0(N) without using extra space. (In another problem of leetcode already had find 2 firt min/max)\n\n\n\n# Complexity\n- Time complexity:n\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def minimizeSum(self, nums: List[int]) -> int:\n        #3 combination\n        nums.sort()\n\n        firstRev = nums[-1] - nums[2]\n        lastRev = nums[-3] - nums[0]\n        bothRev = nums[-2] - nums[1]\n\n        return min(firstRev, lastRev, bothRev)\n```
['Python3']