Practice Maximize Greatness of an Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 0-indexed integer array nums. You are allowed to permute nums into a new array perm of your choosing. We define the greatness of nums be the number of indices 0 <= i < nums.length for which perm[i] > nums[i]. Return the maximum possible greatness you can achieve after permuting nums.
Source: Maximize Greatness of an Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,3,5,2,1,3,1]
Output
4
# Example 2
Input
nums = [1,2,3,4]
Output
3
Constraints
1 <= nums.length <= 10^5
0 <= nums[i] <= 10^9
Related LeetCode Problems
Practice more problems similar to Maximize Greatness of an Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.