Simple C++ approach using 2 pointers || Sorting
\n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n)  O(nlogn)\n\n- Space complexity:\n Add your space complexity here, e.g. O(n)  O(
\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ --> O(nlogn)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --> O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        \n        sort(begin(nums),end(nums));\n        \n        int i = 0;\n        int j = 0;\n        \n        int ans=0;\n        \n        while(i<nums.size()){\n            \n            if(nums[i]>nums[j]){\n                ans++;\n                j++;\n            }\n            \n            i++;\n        }\n        \n        return ans;\n    }\n};\n```
['Array', 'Two Pointers', 'Greedy', 'Sorting', 'C++']