📌📌 C++ || Multiset || Faster || Easy To Understand
Using Multiset\n\n Time Complexity :- O(NlogN)\n\n Space Complexity :- O(N)\n\n\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n    
* ***Using Multiset***\n\n* ***Time Complexity :- O(NlogN)***\n\n* ***Space Complexity :- O(N)***\n\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        \n        int n = nums.size();\n        \n        // declare a multi set\n        \n        multiset<int> s;\n        \n        // push all the elements into multiset\n        \n        for(auto x : nums)\n        {\n            s.insert(x);\n        }\n        \n        int count = 0;\n        \n        // traverse over the nums\n        \n        for(int i = 0; i < n; i++)\n        {\n            // find the upper bound of the nums[i]\n            \n            auto it = s.upper_bound(nums[i]);\n            \n            // if upper bound exist then increment count and erase that number\n            \n            if(it != s.end())\n            {\n                count++;\n                \n                s.erase(it);\n            }\n        }\n        \n        return count;\n    }\n};\n```
['C', 'C++']