C++ Easy Sol || Dont Beat 100% (But Give It a Read)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1. I have Provide two A
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. I have Provide two Approaches below the comment .\n2. Read them and give them a dry run.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nlog(n))$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        int n=nums.size();\n       \n\n\n        //----******BRUTE FORCE****-----\n\n\n\n        // vector<int>temp(n,0);\n        // temp=nums;\n        // sort(temp.begin(),temp.end());\n        // int ans=0;\n        // for(int i=0;i<n;i++){\n        //     for(int j=0;j<n;j++){\n        //         if(temp[j]!=-1 && nums[i]<temp[j]){\n        //             ans++;\n        //             temp[j]=-1;\n        //             break;\n        //         }\n        //     }\n        // }\n        // return ans;\n\n\n\n        //----******TWO_POINTER*****------\n        sort(nums.begin(),nums.end());\n        int i=0,j=0;\n        if(n==1)return 0;\n        while(i<=j && j<n){\n            while(j<n && nums[j]<=nums[i]){\n                j++;\n            }\n            if(j>=n){\n                break;\n            }\n            i++;\n            j++;\n        }\n        return i;\n        \n    }\n};\n```
['C++']