human
Longest Substring having equal count of Vowels and Consonants | Function to return the length of the longest substring having equal number of vowel and consonant.
Generate the array.
Initialize variable to store result.
Stores the sum of subarray.
Map to store indices of the sum.
Loop through the array.
If sum is 0.
Count of vowels and consonants are equal.
Update the maximum length of substring in HashMap.
Store the index of the sum.
Return the maximum length of required substring.
Driver Code"
How can the above be solved in Python?

Give me a code to longest Substring having equal count of Vowels and Consonants and the other steps required?
assistant
#Here is code to longest Substring having equal count of Vowels and Consonants and the other steps required.
 def maxsubstringLength ( S , N ) :
	arr = [ 0 ] * N
	for i in range ( N ) :
		if ( S [ i ] == ' a ' or S [ i ] == ' e ' or S [ i ] == ' i ' or S [ i ] == ' o ' or S [ i ] == ' u ' ) :
			arr [ i ] = 1
		else :
			arr [ i ] = - 1
	maxLen = 0
	curr_sum = 0
	hash = { }
	for i in range ( N ) :
		curr_sum += arr [ i ]
		if ( curr_sum == 0 ) :
			maxLen = max ( maxLen , i + 1 )
		if ( curr_sum in hash . keys ( ) ) :
			maxLen = max ( maxLen , i - hash [ curr_sum ] )
		else :
			hash [ curr_sum ] = i
	return maxLen
S = " geeksforgeeks "
n = len ( S )
print ( maxsubstringLength ( S , n ) )