✅C++ | ✅Two Pointers | ✅Efficient Approach
Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution \n{\npublic:\n    int maximizeGreatness(vector<int>& nums) \n 
# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution \n{\npublic:\n    int maximizeGreatness(vector<int>& nums) \n    {\n        sort(nums.begin(), nums.end());\n        \n        int i=0, j=0, n=nums.size(), cnt=0;\n        while(j<n)\n        {\n            if(nums[i] >= nums[j]) j++;\n            else if(nums[i] < nums[j])\n            {\n                cnt++;\n                i++;\n                j++;\n            }\n        } \n        return cnt;\n    }\n};\n```
['Array', 'Sorting', 'C++']