Find Maximum Greatness

Problem Overview

  • Task: Rearrange an array to maximize greatness, the number of indices i where rearranged[i] > arr[i].
  • Input/Output: Given int array arr, return the maximum greatness as an integer; constraints: 1 ≤ n ≤ 1e5, 1 ≤ arr[i] ≤ 1e9.
  • Context: Models outperforming an original ordering; relevant to ranking, matching, or allocation scenarios.
  • Source: From Twilio interviews; a coding interview problem frequently used as an interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: