Intuitive using two pointers. beats 99%
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\nios::sync_with_stdio(false);\ncin.tie(nullptr);\n        sort(num
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\nios::sync_with_stdio(false);\ncin.tie(nullptr);\n        sort(nums.begin(), nums.end());\n\n        int i=nums.size()-2, j= nums.size()-1;\n        int count = 0;\n\n\n        while(i>-1 && j > -1){\n\n            while(i > -1 && nums[i] == nums[j]){\n                i--;\n            }\n            while(i > -1 && nums[i] < nums[j]){\n                i--;\n                j--;\n                count++;\n            }\n        }\n\n       \n\n\n        return count;\n        \n    }\n};\n```
['C++']