Remove minimum elements
Easy Accuracy: 15.19% Submissions: 383 Points: 2

Given an unsorted array Arr of size N. Find the minimum number of removals required such that twice of minimum element in the array is greater than or equal to the maximum in the array.

Example 1:

N = 9
Arr[] = {4,5,100,9,10,11,12,15,200}
Output: 4
Explanation: In the given array 4 elements 
4, 5, 200 and 100 are removed from the
array to make the array such that
2*minimum >= max (2*9 > 15).

Example 2:

N = 4
Arr[] = {4,7,5,6}
Output: 0
Explanation: We don't need to remove any
element as  4*2 > 7 (Note that min = 4,
max = 7).

Your Task:
You don't need to read input or print anything. Your task is to complete the function minRemoval() which takes the array of integers arr and as parameters and returns an integer denoting the answer.

Expected Time Complexity: O(N*logN)
Expected Auxiliary Space: O(1)

1 ≤ N ≤ 107
1 ≤ Arri ≤ 109

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Remove minimum elements

Output Window