C++ | Two Pointer | Greedy | Sorting | Easy
IntuitionFinding the next greater element for every element (greedy) to maximise the count.Complexity
Time complexity: O(nlogn)

Space complexity: O(1)
Code
# Intuition
Finding the next greater element for every element (greedy) to maximise the count.

# Complexity
- Time complexity: $$O(nlogn)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maximizeGreatness(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int idx = 0;
        int result = 0;
        for(int num: nums){
            if(num > nums[idx]){
                result++;
                idx++;
            }
        }
        return result;
    }
};
```
['Two Pointers', 'Greedy', 'Sorting', 'C++']