O(n) heapq Solution | 235ms | Beats 99%
Complexity\n- Time complexity: O(n)\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# Co
# Complexity\n- Time complexity: $$O(n)$$\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```python3 []\nclass Solution:\n    def minimizeSum(self, nums: List[int]) -> int:\n        low = heapq.nsmallest(3, nums)\n        high = heapq.nlargest(3, nums)\n\n        a = high[0] - low[2] # Remove the first 2\n        b = high[2] - low[0] # Remove the last 2\n        c = high[1] - low[1] # Remove first and last\n\n        return min([a, b, c])\n```
['Python3']