human
Minimum number of operations required to make an array non | Function to count the minimum number of steps required to make arr non - decreasing.
Stores differences.
Stores the max number.
Traverse the array arr [ ].
Update mx.
Update val.
Stores the result.
Iterate until 2 ^ res - 1 is less than val.
Return the answer.
Driver Code.
Given input.
Function call"
Solution in Python:
assistant
#Here is code to minimum number of operations required to make an array non and the other steps required.
 def countMinSteps ( arr , N ) :
	val = 0
	mx = - 10 ** 9
	for i in range ( N ) :
		curr = arr [ i ]
		mx = max ( mx , curr )
		val = max ( val , mx - curr )
	res = 0
	while ( ( 1 << res ) - 1 < val ) :
		res += 1
	return res
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 7 , 6 , 5 ]
	N = len ( arr )
	print ( countMinSteps ( arr , N ) )