USING SORT & HEAP || EASY TO UNDERSTAND || C++
Code\n\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        int ans = 0;\n        sort(nums.begin(),nums.end());\n        priorit
# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        int ans = 0;\n        sort(nums.begin(),nums.end());\n        priority_queue<int,vector<int>,greater<int>> pq;\n        for(auto &i: nums){\n            pq.push(i);\n        }\n        for(auto &i: nums){\n            while(!pq.empty() && i>=pq.top()){\n                pq.pop();\n            }\n            if(pq.empty())return ans;\n            pq.pop();\n            ans++;\n        }\n        return ans;\n    }\n};\n```
['Array', 'Greedy', 'Sorting', 'Heap (Priority Queue)', 'C++']