Remove minimum elements
Submissions: 4888   Accuracy:

21.39%

  Difficulty: Easy   Marks: 2

Given an unsorted array A. Find the minimum number of removals required such that twice of minimum element in the array is greater than the maximum in the array.

Input:
The first line of input contains an integer T denoting the number of test cases. The first line of each test case is N denoting the size of the array. The second line of each test case contains N array elements.

Output:
Print the minimum number of removals.

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 107
1 ≤ Ai ≤ 109
Example:
Input:
1
9
4 5 100 9 10 11 12 15 200

Output:
4

Explanation:
Testcase 1:
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).

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.