human
Length of longest subarray with product equal to a power of 2 | Function to check whether a number is power of 2 or not.
Function to find maximum length subarray having product of element as a perfect power of 2.
Stores current subarray length.
Stores maximum subarray length.
Traverse the given array.
If arr [ i ] is power of 2.
Increment max_length.
Update max_len_subarray.
Otherwise.
Prthe maximum length.
Driver Code.
Given arr.
Function Call"
How can the above be solved in Python?
 What is a code to length of longest subarray with product equal to a power of 2 and the other steps required?
assistant
#Here is code to length of longest subarray with product equal to a power of 2 and the other steps required.
 def isPower ( x ) :
	if ( x != 0 and ( x & ( x - 1 ) ) == 0 ) :
		return True ;
	return False ;
def maximumlength ( arr , N ) :
	max_length = 0 ;
	max_len_subarray = 0 ;
	for i in range ( N ) :
		if ( isPower ( arr [ i ] ) ) :
			max_length += 1 ;
			max_len_subarray = max ( max_length , max_len_subarray ) ;
		else :
			max_length = 0 ;
	print ( max_len_subarray ) ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 5 , 4 , 6 , 8 , 8 , 2 ] ;
	N = len ( arr ) ;
	maximumlength ( arr , N ) ;