You are given an integer array nums.
You may rearrange the values in any order to create a new array perm.
We define greatness as the count of indices i where:
Your task is to determine the highest number of such positions possible by choosing the best permutation of the array.
Return that maximum greatness value.
Input: nums = [2, 2, 1, 4]
Output: 2
Explanation:
One possible arrangement is perm = [4, 2, 2, 1]. perm[i] > nums[i] at indices 0 and 2. No permutation can achieve more than 2.
Input: nums = [5, 1, 3]
Output: 2
Explanation:
A valid permutation is perm = [3, 5, 1]. Greatness count = 2.
Accepted:
Submission: