Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1083 |

@bt8816103042 | 739 |

@SherlockHolmes3 | 444 |

@SHOAIBVIJAPURE | 430 |

@codeantik | 429 |

@shalinibhataniya1097 | 400 |

@ShamaKhan1 | 388 |

@neverevergiveup | 372 |

@amrutakashikar2 | 355 |

@murarry3625 | 350 |

@mahlawatep | 349 |

Complete Leaderboard |

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:**

**Input:
**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:**

**Input:
**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 **n **as parameters and returns an integer denoting the answer.

**Expected Time Complexity:** O(N*logN)

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 ≤ N ≤ 10^{7}

1 ≤ Arr_{i} ≤ 10^{9}

Login 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?

Yes
Remove minimum elements

...