Simple python3 solution | O(n) time, O(1) memory | 250 ms - faster than 95.89% solutions
Complexity\n- Sorting:\n\n  - Time complexity: O(n \cdot \log(n))\n  - Space complexity: O(n)\n\n- Using heap:\n\n  - Time complexity: O(n \cdot \log(k)) = O(n)
# Complexity\n- Sorting:\n\n  - Time complexity: $$O(n \\cdot \\log(n))$$\n  - Space complexity: $$O(n)$$\n\n- Using heap:\n\n  - Time complexity: $$O(n \\cdot \\log(k)) = O(n)$$\n  - Space complexity: $$O(k) = O(1)$$\n\n\nwhere `k = 3`\n\n# Code\n``` python3 []\n# using sorting\n\nclass Solution:\n    def minimizeSum(self, nums: List[int]) -> int:\n        nums.sort()\n        return min(\n            nums[-3] - nums[0],\n            nums[-2] - nums[1],\n            nums[-1] - nums[2],\n        )\n```\n``` python3 []\n# using heap\n\nimport heapq\n\nclass Solution:\n    def minimizeSum(self, nums: List[int]) -> int:\n        prefix = heapq.nsmallest(3, nums)\n        suffix = heapq.nlargest(3, nums)\n        return min(\n            suffix[0] - prefix[2],\n            suffix[1] - prefix[1],\n            suffix[2] - prefix[0],\n        )\n```
['Math', 'Two Pointers', 'Sorting', 'Heap (Priority Queue)', 'Python3']