human
Give me a code to maximum area rectangle by picking four sides from array and the other steps required given the following:
Maximum area rectangle by picking four sides from array | function for finding max area.
traverse through array.
If this is first occurrence of arr [ i ] , simply insert and continue.
If this is second ( or more ) occurrence , update first and second maximum values ..
return the product of dimensions.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to maximum area rectangle by picking four sides from array and the other steps required.
 def findArea ( arr , n ) :
	s = [ ]
	first = 0
	second = 0
	for i in range ( n ) :
		if arr [ i ] not in s :
			s . append ( arr [ i ] )
			continue
		if ( arr [ i ] > first ) :
			second = first
			first = arr [ i ]
		elif ( arr [ i ] > second ) :
			second = arr [ i ]
	return ( first * second )
if __name__ == " _ _ main _ _ " :
	arr = [ 4 , 2 , 1 , 4 , 6 , 6 , 2 , 5 ]
	n = len ( arr )
	print ( findArea ( arr , n ) )