TwilioOA #2
Find Maximum Greatness
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyTwo Pointers
Rearrange the array to maximize the number of indices where rearranged[i] > arr[i].
See "Input" for the standard input/output conventions and constraints added by this site.
Input
n≤100000, and array values are 1..10^9.
Output
Output the maximum value.
Example 1
Input:
3
1 3 5
Output:
2
Example 2
Input:
3
1 1 1
Output:
0
Example 3
Input:
4
1 2 2 3
Output:
2
Editorial
Loading solution…