Explained - Sort & Two Pointer || Very Simple & Easy to Understand Solution
Up vote if you like the solution\n# Approach\n1. Sort the array.\n2. Simply iterate (i) over the array, then check for num[j] which is just larger than nums[i].
#### Up vote if you like the solution\n# Approach\n1. Sort the array.\n2. Simply iterate (i) over the array, then check for num[j] which is just larger than nums[i]. once found increament ans & increament i.\n\nTo understand 2nd point, lets take an example\n\n[1,   1,   1,   2,   3,   3,   5] \n..i,j\n\n[1,   1,   1,   2,   3,   3,   5] => ans = 1;\n. i ...........j\n\n[1,   1,   1,   2,   3,   3,   5] => ans = 2;\n..... i. ..........j\n\n[1,   1,   1,   2,   3,   3,   5] => ans = 3;\n ......... i . . . . . . j\n\n[1,   1,   1,   2,   3,   3,   5] => ans = 4;\n . . . . . . . .i . . . . . j\n\n\n\n# Code\n```\n\nint maximizeGreatness(vector<int>& nums) {\n    sort(nums.begin(), nums.end());\n    int i = 0, j = 0, ans = 0;\n    while(j < nums.size()){\n        if(nums[j] > nums[i]) { i++; ans++; }\n        j++;\n    }\n    return ans;\n}\n\n```\n\n<b>Here is an article of my interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted
['C++']