JavaScript | Sort | Two Pointer | TC O(n log n) | SC O(n)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n log n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximizeGreatness = function(nums) {\n    nums.sort((a, b) => a - b);\n    let i = 0, j = 0;\n    while (j < nums.length) {\n        if (nums[i] < nums[j]) {\n            i++;\n        }\n        j++;\n    }\n    return i;\n};\n```
['Sorting', 'JavaScript']