Python - Sort + Two Pointer
IntuitionTo find the greatest perm, it's good to make every greater element just surpass the shorter elementApproachsort and two pointerComplexity
Time complexi
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
To find the greatest perm, it's good to make every greater element just surpass the shorter element

# Approach
<!-- Describe your approach to solving the problem. -->
sort and two pointer

# 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
```python3 []
class Solution:
    def maximizeGreatness(self, nums: List[int]) -> int:
        # [1,3,5,2,1,3,1]

        # [1,1,1,2,3,3,5]
        # sort and two ptr

        nums.sort()
        left = 0
        for right in range(len(nums)):
            if nums[right] > nums[left]:
                left += 1
        return left
```
['Python3']