Easy Peasy C++ code | O(n logn) time complexity | O(1) Space Complexity
Complexity\n- Time complexity:\nO(n logn) for sorting the vector\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int minimizeSum(vector
# Complexity\n- Time complexity:\nO(n logn) for sorting the vector\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimizeSum(vector<int>& a) {\n        int n = a.size();\n        if(n==3){\n            return 0;\n        }\n        sort(a.begin(),a.end());\n        int one = a[n-1] - a[2];\n        int two = a[n-3] - a[0];\n        int three = a[n-2] - a[1];\n        return min({one,two,three});\n    }\n};\n```
['C++']