Sort and take sum
\n\n# Code\n\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& happiness, int k) {\n        long long ans = 0;\n        sort(happiness.
\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& happiness, int k) {\n        long long ans = 0;\n        sort(happiness.begin(), happiness.end());\n        for(int i = happiness.size() - 1, j = 0; i >= 0 && k > 0; --i, j++, k--){\n            if(happiness[i] - j > 0) ans += happiness[i] - j;\n        } \n        return ans;\n    }\n};\n```\n\n---\n\n\n<b>Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n---
['C++']