Tap here to switch tabs
Problem
Submissions

Problem: Maximize Greatness of an Array

med
30 min
Try to solve the Maximize Greatness of an Array problem.

Statement

You are given an integer array nums. You may rearrange the elements of nums to form another array perm of the same length.

Define the greatness of perm as the number of indices i such that perm[i] > nums[i]. Return the maximum possible greatness over all rearrangements perm of nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Greatness of an Array

med
30 min
Try to solve the Maximize Greatness of an Array problem.

Statement

You are given an integer array nums. You may rearrange the elements of nums to form another array perm of the same length.

Define the greatness of perm as the number of indices i such that perm[i] > nums[i]. Return the maximum possible greatness over all rearrangements perm of nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9