human
Leftmost and rightmost indices of the maximum and the minimum element of an array | Python3 implementation of the approach.
If found new minimum.
If arr [ i ] = min then rightmost index for min will change.
If found new maximum.
If arr [ i ] = max then rightmost index for max will change.
Driver code"
How can the above be solved in Python?

Give me a code to leftmost and rightmost indices of the maximum and the minimum element of an array and the other steps required?
assistant
#Here is code to leftmost and rightmost indices of the maximum and the minimum element of an array and the other steps required.
 def findIndices ( arr , n ) :
	leftMin , rightMin = 0 , 0
	leftMax , rightMax = 0 , 0
	min_element = arr [ 0 ]
	max_element = arr [ 0 ]
	for i in range ( n ) :
		if ( arr [ i ] < min_element ) :
			leftMin = rightMin = i
			min_element = arr [ i ]
		elif ( arr [ i ] == min_element ) :
			rightMin = i
		if ( arr [ i ] > max_element ) :
			leftMax = rightMax = i
			max_element = arr [ i ]
		elif ( arr [ i ] == max_element ) :
			rightMax = i
	print ( " Minimum ▁ left ▁ : ▁ " , leftMin )
	print ( " Minimum ▁ right ▁ : ▁ " , rightMin )
	print ( " Maximum ▁ left ▁ : ▁ " , leftMax )
	print ( " Maximum ▁ right ▁ : ▁ " , rightMax )
if __name__ == " _ _ main _ _ " :
	arr = [ 2 , 1 , 1 , 2 , 1 , 5 , 6 , 5 ]
	n = len ( arr )
	findIndices ( arr , n )