human
Rearrange an array in maximum minimum form | Set 1 | Prints max at first position , min at second position second max at third position , second min at fourth position and so on ..
Auxiliary array to hold modified array.
Indexes of smallest and largest elements from remaining array ..
To indicate whether we need to copy rmaining largest or remaining smallest at next position.
Store result in temp [ ].
Copy temp [ ] to arr [ ].
Driver code"
Solution in Python:
 Write me a code to rearrange an array in maximum minimum form and the other steps required?
assistant
#Here is code to rearrange an array in maximum minimum form and the other steps required.
 def rearrange ( arr , n ) :
	temp = n * [ None ]
	small , large = 0 , n - 1
	flag = True
	for i in range ( n ) :
		if flag is True :
			temp [ i ] = arr [ large ]
			large -= 1
		else :
			temp [ i ] = arr [ small ]
			small += 1
		flag = bool ( 1 - flag )
	for i in range ( n ) :
		arr [ i ] = temp [ i ]
	return arr
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
n = len ( arr )
print ( " Original ▁ Array " )
print ( arr )
print ( " Modified ▁ Array " )
print ( rearrange ( arr , n ) )