JAVA | Sorting + Two pointers ✅
Intuition:\nPlace the next greater number in place of the current number.\n\n---\n# Solution:\n\nclass Solution {\n    public int maximizeGreatness(int[] nums) 
# Intuition:\nPlace the next greater number in place of the current number.\n\n---\n# Solution:\n```\nclass Solution {\n    public int maximizeGreatness(int[] nums) {\n        Arrays.sort(nums);\n        int ans = 0;\n        for (int i = 0, j = 1; j < nums.length; j++) {\n            if (nums[i] < nums[j]) {\n                ans++; i++;\n            }\n        }\n        \n        return ans;\n    }\n}\n```\n---\n*You can check out my video explanation (Channel link in profile bio).*\n\n---\n##### Time complexity: $$O(n.logn)$$\n\n\n
['Two Pointers', 'Sorting', 'Java']