Search⌘ K
AI Features

Solution: Maximize Greatness of an Array

C# solution for the Maximize Greatness of an Array problem using the Two Pointers pattern.

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:

  • 11 \leq nums.length 105\leq 10^5 ...