C++ Solution -  3 Method to Solve [Easy and Concise]
Solution 1 - Easy Solution Using Map\n\n\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        int maxi=INT_MIN;\n        int n=nu
# Solution 1 - Easy Solution Using Map\n\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        int maxi=INT_MIN;\n        int n=nums.size();\n        map<int,int>m;\n        for(int i=0;i<n;i++){\n            m[nums[i]]++;\n            maxi=max(maxi,m[nums[i]]);\n        }\n        return nums.size()-maxi;\n    }\n};\n```\n\n---\n\n# Solution 2 - By Iteration\n\n```\n  int maximizeGreatness(vector<int>& A) {\n        sort(A.begin(), A.end());\n        int res = 0;\n        for (int& a : A)\n            if (a > A[res])\n                res++;\n        return res;\n    }\n```\n\n---\n\n\n\n# Solution 3 - Simple Solution\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;\n        int last = n-1;\n        while(j<=last)\n        {\n            if(nums[i]<nums[j])\n            {\n                count++;\n                i++;\n                j++;\n            }\n            else\n            {\n                j++;\n            }\n        }\n        return count;\n    }\n};\n```\n\n![24f080eb-397a-4a09-a9f5-6a9a315c955f_1675822350.8603303.png](https://assets.leetcode.com/users/images/0b3d4300-2e0d-49be-8edd-6e71a9d2b7a1_1679157326.0122333.png)\n\n
['Two Pointers', 'Ordered Map', 'C', 'Sorting', 'C++']