Python 3   ||   6 lines,  sort and iterate   ||   T/S: 91% / 64%
\nclass Solution:\n    def maximumHappinessSum(self, happiness: List[int], k: int) -> int:\n        \n        happiness.sort(reverse=True)\n        \n        fo
```\nclass Solution:\n    def maximumHappinessSum(self, happiness: List[int], k: int) -> int:\n        \n        happiness.sort(reverse=True)\n        \n        for i in range(k):\n\n            extra = happiness[i] - i\n            if extra <= 0: return ans\n            ans+= extra\n\n        return ans\n```\n[https://leetcode.com/problems/maximize-happiness-of-selected-children/submissions/1285576262/](https://leetcode.com/problems/maximize-happiness-of-selected-children/submissions/1285576262/)\n\nI could be wrong, but I think that time complexity is *O*(*N*log*N*) and space complexity is *O*(*N*), in which *N* ~ `len(nums)`.
['Python3']