Easy to Understand || brute force || solution without using greedy algo
\n\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& happiness, int k) {\n        sort(happiness.begin(),happiness.end()); // sorting s
\n```\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& happiness, int k) {\n        sort(happiness.begin(),happiness.end()); // sorting so that the happiest child is at the last index\n        long long int ans= 0;\n        int count=0;\n        int size= happiness.size();\n        while(count<k){\n            int temp= happiness.at(size-1); \n            happiness.pop_back();\n            if(temp>0 && temp>=count){\n            ans= ans+ (temp-count);  // with every count other children\'s happiness drops by 1\n            count++;\n            size--;\n            }\n            else{\n                return ans;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']