human
Minimize difference between maximum and minimum array elements by exactly K removals | Function to minimize the difference of the maximum and minimum array elements by removing K elements.
Base Condition.
Sort the array.
Initialize left and right pointers.
Iterate for K times.
Removing right element to reduce the difference.
Removing the left element to reduce the difference.
Print the minimum difference.
Driver Code.
Function Call"
Solution in Python:

Write me a code to minimize difference between maximum and minimum array elements by exactly K removals and the other steps required?
assistant
#Here is code to minimize difference between maximum and minimum array elements by exactly K removals and the other steps required.
 def minimumRange ( arr , N , K ) :
	if ( K >= N ) :
		print ( 0 , end = ' ' ) ;
		return ;
	arr . sort ( ) ;
	left = 0 ; right = N - 1 ;
	for i in range ( K ) :
		if ( arr [ right - 1 ] - arr [ left ] < arr [ right ] - arr [ left + 1 ] ) :
			right -= 1 ;
		else :
			left += 1 ;
	print ( arr [ right ] - arr [ left ] , end = ' ' ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 5 , 10 , 12 , 14 , 21 , 54 , 61 ] ;
	N = len ( arr ) ;
	K = 4 ;
	minimumRange ( arr , N , K ) ;