human
Maximum sum subset having equal number of positive and negative elements | Function to find maximum sum subset with equal number of positive and negative elements.
Loop to store the positive and negative elements in two different array.
Sort both the array.
Pointers starting from the highest elements.
Find pairs having sum greater than zero.
Driver code"
How can the above be solved in Python?

Can you provide a code to maximum sum subset having equal number of positive and negative elements and the other steps required?
assistant
#Here is code to maximum sum subset having equal number of positive and negative elements and the other steps required.
 def findMaxSum ( arr , n ) :
	a = [ ]
	b = [ ]
	for i in range ( n ) :
		if ( arr [ i ] > 0 ) :
			a . append ( arr [ i ] )
		elif ( arr [ i ] < 0 ) :
			b . append ( arr [ i ] )
	a . sort ( )
	b . sort ( )
	p = len ( a ) - 1
	q = len ( b ) - 1
	s = 0
	while ( p >= 0 and q >= 0 ) :
		if ( a [ p ] + b [ q ] > 0 ) :
			s = s + a [ p ] + b [ q ]
		else :
			break
		p = p - 1
		q = q - 1
	return s
arr1 = [ 1 , - 2 , 3 , 4 , - 5 , 8 ]
n1 = len ( arr1 )
print ( findMaxSum ( arr1 , n1 ) )