human
Maximum length of subarray such that sum of the subarray is even | Function to find Length of the longest subarray such that Sum of the subarray is even.
Check if Sum of complete array is even.
if ( Sum % 2 == 0 ) : total Sum is already even.
Find an index i such the a [ i ] is odd and compare Length of both halfs excluding a [ i ] to find max Length subarray.
Driver Code"
Solution in Python:
assistant
#Here is code to maximum length of subarray such that sum of the subarray is even and the other steps required.
 def maxLength ( a , n ) :
	Sum = 0
	Len = 0
	for i in range ( n ) :
		Sum += a [ i ]
		return n
	for i in range ( n ) :
		if ( a [ i ] % 2 == 1 ) :
			Len = max ( Len , max ( n - i - 1 , i ) )
	return Len
a = [ 1 , 2 , 3 , 2 ]
n = len ( a )
print ( maxLength ( a , n ) )