human
Maximum Subset Sum possible by negating the entire sum after selecting the first Array element | Function returns maximum subset sum from the given array =.
Case 2 : Negate values from A [ 1 ] to A [ N - 1 ].
Include only positives for max subset sum.
Return max sum obtained.
Function to return maximum of the maximum subset sum calculated for the two cases.
Case 1.
Case 2.
Modifying the sum.
Including first element.
Negating again.
Return the required answer.
Driver Code"
How can the above be solved in Python?
 ... What is a code to maximum Subset Sum possible by negating the entire sum after selecting the first Array element and the other steps required?
assistant
#Here is code to maximum Subset Sum possible by negating the entire sum after selecting the first Array element and the other steps required.
 def maxSubset ( A , flag ) :
	n = len ( A )
	sum = 0 ;
	if ( flag ) :
		for i in range ( 1 , n ) :
			A [ i ] = - A [ i ]
	for i in range ( 1 , n ) :
		if ( A [ i ] > 0 ) :
			sum += A [ i ]
	return sum
def findBest ( A ) :
	x = maxSubset ( A , 0 )
	y = maxSubset ( A , 1 )
	y = - y
	y += A [ 0 ]
	y = - y
	return max ( x , y )
if __name__ == " _ _ main _ _ " :
	A = [ 1 , 10 , 4 , - 6 , 3 ]
	print ( findBest ( A ) )