Two Pointer||C++
\n\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n       sort(nums.begin(),nums.end());\n        int i=0,j=1;\n        while(j<nums
\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n       sort(nums.begin(),nums.end());\n        int i=0,j=1;\n        while(j<nums.size())\n        {\n            if(nums[i]==nums[j])\n                j++;\n            else {\n                i++;\n                j++;\n            }\n        } \n        return i;\n    }\n};\n```
[]