Simple Sorting || Implementation
Maximize-Happiness-Of-Selected-Children\n\n# Code\n\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& h, int k) {\n        long long an
# Maximize-Happiness-Of-Selected-Children\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& h, int k) {\n        long long ans = 0;\n        sort(h.rbegin(), h.rend());\n        int i = 0, m = 0;\n        while(k--){\n            if(h[i] - m < 0) break;\n            else ans += h[i] - m;\n            i++;\n            m++;\n        }\n        return ans;\n    }\n};\n```\n![Cute Kitti.png](https://assets.leetcode.com/users/images/f183d410-9bb2-4f05-b5ee-579f83655a42_1715256749.3965151.png)\n
['C++']