Remove minimum elements from the array such that 2 * min becomes more than max | Python3 program to remove minimum elements from the array such that 2 * min becomes more than max ; Function to remove minimum elements from the array such that 2 * min becomes more than max ; Sort the array ; To store the required answer ; Traverse from left to right ; Update the answer ; Return the required answer ; Driver code ; Function call
from bisect import bisect_left as upper_bound NEW_LINE def Removal ( v , n ) : NEW_LINE INDENT v = sorted ( v ) NEW_LINE ans = 10 ** 9 NEW_LINE for i in range ( len ( v ) ) : NEW_LINE INDENT j = upper_bound ( v , ( 2 * ( a [ i ] ) ) ) NEW_LINE ans = min ( ans , n - ( j - i - 1 ) ) NEW_LINE DEDENT return ans NEW_LINE DEDENT a = [ 4 , 5 , 100 , 9 , 10 , 11 , 12 , 15 , 200 ] NEW_LINE n = len ( a ) NEW_LINE print ( Removal ( a , n ) ) NEW_LINE