C++ || Easy approach
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(nlogn)\n\n- Space complexity:O(n)\n\n# Code\n\nclass Solution {\npublic:\n    int max
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:$$O(nlogn)$$\n\n- Space complexity:$$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        //vector<int>v;\n        //v=nums;\n        sort(nums.begin(), nums.end());\n        //map<int, int>m;\n        //for(int i=0; i<v.size(); i++){m[v[i]]++;}\n        int cnt=0, i=0, j=1;\n        // for(int i=0; i<nums.size(); i++){\n        //     int pos=upper_bound(v.begin(), v.end(), nums[i])-v.begin();\n        //     //cout<<pos<<endl;\n        //     if(pos!=v.size()){\n        //         cnt++;\n        //         v.erase(v.begin()+pos);\n        //     }\n        // }\n        while(j<nums.size()){\n            if(nums[i]<nums[j]){\n                i++; j++; cnt++;\n            }\n            else{\n                j++;\n            }\n        }\n        return cnt;\n    }\n};\n```
['C++']