2592. Maximize Greatness of an Array || Java
\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
```\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        {\n             if(nums[i]<nums[j])\n             {\n                 ans++;\n                 i++;\n             }\n        }\n        return ans;\n    }\n}\n```
['Sorting']