Simple JAVA Solution || Sorting and turns || Greedy
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(NlogN)\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```\nclass Solution {\n    public long maximumHappinessSum(int[] hap, int k) {\n        Arrays.sort(hap);\n        int len=hap.length;\n        int turns=0;\n        long sum=0;\n        for(int i=len-1;i>=0;i--){\n            sum=sum+Math.max(0,hap[i]-turns);\n            turns++;\n            if(turns>=k) break;\n            \n        }\n        return sum;\n    }\n}\n```
['Greedy', 'Java']