human
Give me a code to find maximum of minimum for every window size in a given array and the other steps required given the following:
Find maximum of minimum for every window size in a given array | An efficient Python3 program to find maximum of all minimums of windows of different sizes.
Used to find previous and next smaller.
Initialize elements of left [ ] and right [ ].
Fill elements of left [ ] using logic discussed on www . geeksforgeeks . org / next - greater - element https :.
Empty the stack as stack is going to be used for right [ ].
Fill elements of right [ ] using same logic.
Create and initialize answer array.
Fill answer array by comparing minimums of all . Lengths computed using left [ ] and right [ ].
Length of the interval.
arr [ i ] is a possible answer for this Length ' Len ' interval , check if arr [ i ] is more than max for 'Len  .
Some entries in ans [ ] may not be filled yet . Fill them by taking values from right side of ans [ ].
Print the result.
Driver Code"
Solution in Python:
assistant
#Here is code to find maximum of minimum for every window size in a given array and the other steps required.
 def printMaxOfMin ( arr , n ) :
	s = [ ]
	left = [ - 1 ] * ( n + 1 )
	right = [ n ] * ( n + 1 )
	for i in range ( n ) :
		while ( len ( s ) != 0 and arr [ s [ - 1 ] ] >= arr [ i ] ) :
			s . pop ( )
		if ( len ( s ) != 0 ) :
			left [ i ] = s [ - 1 ]
		s . append ( i )
	while ( len ( s ) != 0 ) :
		s . pop ( )
	for i in range ( n - 1 , - 1 , - 1 ) :
		while ( len ( s ) != 0 and arr [ s [ - 1 ] ] >= arr [ i ] ) :
			s . pop ( )
		if ( len ( s ) != 0 ) :
			right [ i ] = s [ - 1 ]
		s . append ( i )
	ans = [ 0 ] * ( n + 1 )
	for i in range ( n + 1 ) :
		ans [ i ] = 0
	for i in range ( n ) :
		Len = right [ i ] - left [ i ] - 1
		ans [ Len ] = max ( ans [ Len ] , arr [ i ] )
	for i in range ( n - 1 , 0 , - 1 ) :
		ans [ i ] = max ( ans [ i ] , ans [ i + 1 ] )
	for i in range ( 1 , n + 1 ) :
		print ( ans [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 10 , 20 , 30 , 50 , 10 , 70 , 30 ]
	n = len ( arr )
	printMaxOfMin ( arr , n )