human
Maximize count of 0 s in left and 1 s in right substring by splitting given Binary string | Function to maximize the sum of the count of zeros and ones in the left and right substring.
Count the total numbers of ones in str.
To store the count of zeros and ones while traversing string.
Iterate the given and update the maximum sum.
Update the maximum Sum.
Driver Code.
Given binary string.
Function call"
Solution in Python:
assistant
#Here is code to maximize count of 0 s in left and 1 s in right substring by splitting given Binary string and the other steps required.
 def maxSum ( str ) :
	maximumSum = 0
	totalOnes = 0
	for i in str :
		if i == '1' :
			totalOnes += 1
	zero = 0
	ones = 0
	i = 0
	while i < len ( str ) :
		if ( str [ i ] == '0' ) :
			zero += 1
		else :
			ones += 1
		maximumSum = max ( maximumSum , zero + ( totalOnes - ones ) )
		i += 1
	return maximumSum
if __name__ == ' _ _ main _ _ ' :
	str = "011101"
	print ( maxSum ( str ) )