Two pointer approach after sorting
Approach\n\nIf we sort the array the problem becomes simple. The main idea is to not actually calculate the perm array but find the indexes where nums[i+1] > nu
# Approach\n\nIf we sort the array the problem becomes simple. The main idea is to not actually calculate the perm array but find the indexes where nums[i+1] > nums[i] (after sorting) and increase the counter.\n\n# Complexity\n- Time complexity:\nO(NlogN)\n\n- Space complexity:\n O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) \n    {\n       sort(nums.begin(),nums.end());\n          \n            int high=1;\n            int low=0;\n            int count=0;\n            while(high<nums.size())\n            {\n                if(nums[low]==nums[high])\n                    \n                {\n                    high++;\n                }\n                else\n                {\n                    low++;\n                   high++;\n                    count++;\n                }\n            }\n            return count;\n            \n        \n    }\n};\n```
['Two Pointers', 'Sorting', 'C++']