Easy Solution | beats 100 % | Explanation
Approach\n Describe your approach to solving the problem. \nGreedy\n# Complexity\n- Time complexity:O(n) n = len(happiness) + n log n\n Add your time complexity
# Approach\n<!-- Describe your approach to solving the problem. -->\nGreedy\n# Complexity\n- Time complexity:O(n) n = len(happiness) + n log n\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunc maximumHappinessSum(happiness []int, k int) int64 {\n    // sorting in reverse order and we greedily start from\n    // biggest group\n    sort.Slice(happiness, func(i, j int) bool{\n        return happiness[i] > happiness[j]\n    })\n    // actually you can decrese even if t cause negative number\n    // and greedy approach still suits \n    totalHappiness := 0    \n    for i := 0; i < k ; i++{\n        if happiness[i] - i > 0{\n            // substracting i cuz it is cost to come to that point\n            totalHappiness += happiness[i] - i\n        }\n    }\n\n    return int64(totalHappiness)\n}\n```
['Array', 'Greedy', 'Sorting', 'Go']