O(n) time, O(1) space, no sorting required
Approach\nNo need to sort the array instead do the following:\n\nFind 1st 3 minimum values (low1<=low2<=low3) and 1st 3 maximum values (high1>=high2>=high3)\n\n
# Approach\nNo need to sort the array instead do the following:\n\nFind 1st 3 minimum values (low1<=low2<=low3) and 1st 3 maximum values (high1>=high2>=high3)\n\nAnswer is minimum difference between the pairs (high1,low3), (high2,low2), (high3,low1)\n# Complexity\n- Time complexity:\nO(n) - finding min and max values of array\n\n- Space complexity:\nO(1)\n\n# Code\n```python3 []\nclass Solution:\n    def minimizeSum(self, nums: List[int]) -> int:\n        low1 = min(nums)\n        nums.remove(low1)\n\n        low2 = min(nums)\n        nums.remove(low2)\n\n        low3 = min(nums)\n\n        high1 = max(nums)\n\n        if len(nums) == 1:\n            return 0\n        elif len(nums) == 2:\n            return min(high1-low3,low3-low2,low2-low1)\n\n        nums.remove(high1)\n\n        high2 = max(nums)\n        nums.remove(high2)\n\n        high3 = max(nums)\n\n        return min(high1-low3,high2-low2,high3-low1)\n        \n```
['Python3']