human
Maximum length of subarray such that all elements are equal in the subarray | Function to find the longest subarray with same element.
Check if the elements are same then we can increment the length.
Reinitialize j.
Compare the maximum length e with j.
Return max length.
Given list arr [ ].
Function call"
How can the above be solved in Python?
 ... Write me a code to maximum length of subarray such that all elements are equal in the subarray and the other steps required?
assistant
#Here is code to maximum length of subarray such that all elements are equal in the subarray and the other steps required.
 def longest_subarray ( arr , d ) :
	( i , j , e ) = ( 0 , 1 , 0 )
	for i in range ( d - 1 ) :
		if arr [ i ] == arr [ i + 1 ] :
			j += 1
		else :
			j = 1
		if e < j :
			e = j
	return e
arr = [ 1 , 2 , 3 , 4 ]
N = len ( arr )
print ( longest_subarray ( arr , N ) )