Simple 2 pointer Solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int i = 0;\n        int j = 1;\n        int n = nums.size();\n\n        while(j < n){\n            if(nums[j] > nums[i]){\n                i++;\n                j++;\n            }\n            else{\n                j++;\n            }\n        }\n\n        return i;\n    }\n};\n```
['C++']