Python | Easy
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n    def maximumHappinessSum(self, happiness: List[int], k: int) -> int:\n        happines
[see the Successfully Accepted Submission](https://leetcode.com/problems/maximize-happiness-of-selected-children/submissions/1253228363/?envType=daily-question&envId=2024-05-09)\n\n# Code\n```\nclass Solution:\n    def maximumHappinessSum(self, happiness: List[int], k: int) -> int:\n        happiness.sort(reverse=True)\n        indx = 0\n        totalHappinessSum = 0\n\n        while k > 0:\n            happiness[indx] = max(happiness[indx] - indx, 0)\n            totalHappinessSum += happiness[indx]\n            indx += 1\n            k -= 1\n\n        return totalHappinessSum\n```\n![image](https://assets.leetcode.com/users/images/b1e4af48-4da1-486c-bc97-b11ae02febd0_1696186577.992237.jpeg)
['Python3']