2 Pointer Approach
Space Complexity : O(1)\n### Time Complexity : O(n logn)\n\n# Code\n\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) \n    {\n        /
### Space Complexity : O(1)\n### Time Complexity : O(n logn)\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) \n    {\n        // arrnge the values in asscending order\n        sort(nums.begin(),nums.end());\n        \n        int st=0;\n        int en=1;\n        int cnt=0;\n        \n        while(en < nums.size())\n        {\n            // finding next greater\n            while(en < nums.size() && nums[en] <= nums[st])\n            {\n                en++;\n            }\n            \n            if(en==nums.size()) break;\n            \n            st++;\n            en++;\n            cnt++;\n        }\n        \n        return cnt;\n    }\n};\n```
['Two Pointers', 'Sorting', 'C++']