human
Longest substring with count of 1 s more than 0 s | Function to find longest substring having count of 1 s more than count of 0 s ..
To store sum ..
To store first occurrence of each sum value ..
To store maximum length ..
To store current substring length ..
Add 1 if current character is 1 else subtract 1..
If sum is positive , then maximum length substring is bin1 [ 0. . i ].
If sum is negative , then maximum length substring is bin1 [ j + 1. . i ] , where sum of substring bin1 [ 0. . j ] is sum - 1..
Make entry for this sum value in hash table if this value is not present ..
Driver code"
Solution in Python:

=====
Can you provide a code to longest substring with count of 1 s more than 0 s and the other steps required?
assistant
#Here is code to longest substring with count of 1 s more than 0 s and the other steps required.
 def findLongestSub ( bin1 ) :
	n = len ( bin1 )
	sum = 0
	prevSum = { i : 0 for i in range ( n ) }
	maxlen = 0
	for i in range ( n ) :
		if ( bin1 [ i ] == '1' ) :
			sum += 1
		else :
			sum -= 1
		if ( sum > 0 ) :
			maxlen = i + 1
		elif ( sum <= 0 ) :
			if ( ( sum - 1 ) in prevSum ) :
				currlen = i - prevSum [ sum - 1 ]
				maxlen = max ( maxlen , currlen )
		if ( ( sum ) not in prevSum ) :
			prevSum [ sum ] = i
	return maxlen
if __name__ == ' _ _ main _ _ ' :
	bin1 = "1010"
	print ( findLongestSub ( bin1 ) )