Kotlin "oneliner"
Complexity\n- Time complexity: O(n*log(n))\n- Space complexity: O(n)\n\n# Code\n\nclass Solution {\n    fun maximumHappinessSum(happiness: IntArray, k: Int) =\n
# Complexity\n- Time complexity: $$O(n*log(n))$$\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution {\n    fun maximumHappinessSum(happiness: IntArray, k: Int) =\n        happiness.sortedDescending().asSequence().withIndex()\n            .take(k)\n            .map { it.value.toLong() - it.index }\n            .takeWhile { it > 0 }\n            .sum()\n}\n```
['Kotlin']