C++| Easy to understand | O(n logn)
Intuition\nStart from the highest happiness, and keep on adding it to the result.\n\n# Approach\n1. Sort the array in decreasing order of happiness\n2. Iterate 
# Intuition\nStart from the highest happiness, and keep on adding it to the result.\n\n# Approach\n1. Sort the array in decreasing order of happiness\n2. Iterate over the array and keep on adding the current happiness into the result. As we cannot have negative happiness, add 0, if the happiness is becoming negative.\n3. Current happiness is happiness - the iteration we are in.\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& happiness, int k) {\n        sort(happiness.rbegin(), happiness.rend());\n        long long res = 0;\n        for(int i = 0; i < k; ++i)\n        {\n            res += max(happiness[i] - i, 0);\n        }\n        return res;\n    }\n};\n```
['C++']