SIMPLE TWO-POINTER C++ SOLUTION
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 
# 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:o(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        int n = nums.size();\n        sort(nums.begin(), nums.end()); \n        int count = 0;\n        int i = 0;\n        int  j = 1; // for finding greater element\n        while(j < n){\n            if(nums[i] < nums[j]){\n                count++;// satisifes the condtion \n                i++;\n                j++; \n            } else {\n                j++; // Only move the second pointer if no condition is met\n            }\n        }\n        return count;\n    }\n};\n```
['C++']