C++ || Easy and Simple ✔
\n\n\n# Code\n\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        \n       map<int,int>m;\n        for(int x:nums) m[x]++ ;\n  
\n\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        \n       map<int,int>m;\n        for(int x:nums) m[x]++ ;\n        \n          sort(nums.begin(),nums.end()) ;\n         int ans=0;\n         for(int x:nums) {\n               \n               auto it=m.upper_bound(x) ;\n              \n               if(it!=m.end()){\n                    ans++;\n                   \n                    if(it->second==1) {\n                      m.erase(it->first) ; \n                    }\n                   else{\n                       m[it->first]--;\n                   }\n               }\n             \n              \n         }\n        return ans;\n    }\n};\n```
['C++']