human
Longest Sub | Function to return the max length of the sub - array that have the maximum average ( average value of the elements ).
Finding the maximum value.
If consecutive maximum found.
Find the max length of consecutive max.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to longest Sub and the other steps required.
 def maxLenSubArr ( a , n ) :
	cm , Max = 1 , 0
	for i in range ( 0 , n ) :
		if a [ i ] > Max :
			Max = a [ i ]
	i = 0
	while i < n - 1 :
		count = 1
		if a [ i ] == a [ i + 1 ] and a [ i ] == Max :
			for j in range ( i + 1 , n ) :
				if a [ j ] == Max :
					count += 1
					i += 1
				else :
					break
			if count > cm :
				cm = count
		else :
			i += 1
		i += 1
	return cm
if __name__ == " _ _ main _ _ " :
	arr = [ 6 , 1 , 6 , 6 , 0 ]
	n = len ( arr )
	print ( maxLenSubArr ( arr , n ) )