Maximize Greatness Iterative
Code
# Code
```python3 []
class Solution:
    def maximizeGreatness(self, nums: List[int]) -> int:
        nums.sort()#sort array in increasing order to achive greedy solution
        count = 0
        i = 0
        j = i + 1
        n = len(nums)
        while j < n:#use a 2 pointer approach to iterate the nums array since we greedily make the best pairing possible at each step
            if nums[j] > nums[i]:
                count += 1
                i += 1
            j += 1
        return count
```
['Python3']