100% TIME AND SPACE C++ SIMPLE SOL - PRIORITY QUEUE
Intuition\n Describe your first thoughts on how to solve this problem. \nHere we will use the priority queue to store the smallest numbers in the order and will
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nHere we will use the priority queue to store the smallest numbers in the order and will increment the counter as soon as we get the number greater than it and pop the element from the queue simultanousely.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int count = 0;\n        priority_queue<int, vector<int>, greater<int>> pq;\n        for(int i=0;i<nums.size();i++){\n            if(!pq.empty()){\n                if(nums[i] > pq.top()){\n                    count++;\n                    pq.pop();\n                }\n            }\n            pq.push(nums[i]);\n        }\n        return count;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']