human
Can you provide a code to subtraction in the Array and the other steps required given the following:
Subtraction in the Array | Function to perform the given operation on arr [ ].
Skip elements which are 0.
Pick smallest non - zero element.
If all the elements of arr [ ] are 0.
Driver code"
Solution in Python:
assistant
#Here is code to subtraction in the Array and the other steps required.
 def operations ( arr , n , k ) :
	arr . sort ( ) ;
	i = 0 ; sum = 0 ;
	while ( k > 0 ) :
		while ( i < n and arr [ i ] - sum == 0 ) :
			i += 1 ;
		if ( i < n and arr [ i ] - sum > 0 ) :
			print ( arr [ i ] - sum , end = " ▁ " ) ;
			sum = arr [ i ] ;
		else :
			print ( 0 ) ;
		k -= 1 ;
k = 5 ;
arr = [ 3 , 6 , 4 , 2 ] ;
n = len ( arr ) ;
operations ( arr , n , k ) ;