5 Lines Code ||  DP || Easy C++ || Beats 100% ✅✅
\n# Approach\n Describe your approach to solving the problem. \nWe have to choose two numbers from minimum or maximum but which two elements will we choose.....
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe have to **choose two numbers** from **minimum or maximum** but which two elements will we **choose**.........\uD83E\uDD14\uD83E\uDD14\uD83E\uDD14\uD83E\uDD14\nHere I used **dp concept** to select two elements so as to **minimize the score sum**.\n\n# Complexity\n- Time complexity:O(N * Log(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```\nclass Solution {\npublic:\n    int solve(vector<int> arr,int i,int j,int k)\n    {\n         if(k>=2) return arr[j]-arr[i];\n         return min(solve(arr,i+1,j,k+1),solve(arr,i,j-1,k+1));\n    }\n    int minimizeSum(vector<int>& arr) {\n        sort(arr.begin(),arr.end());\n        if(arr.size()<=3) return 0;\n        return solve(arr,0,arr.size()-1,0);\n    }\n};\n```\n![upvote.jpg](https://assets.leetcode.com/users/images/897fffe7-61e0-4168-b721-02355350e7cc_1691338716.6880965.jpeg)\n
['Array', 'Dynamic Programming', 'Greedy', 'C++']