human
Add n binary strings | This function adds two binary strings and return result as a third string.
Initialize result.
Initialize digit sum.
Traverse both strings starting from last characters.
Compute sum of last digits and carry.
If current digit sum is 1 or 3 , add 1 to result.
Compute carry.
Move to next digits.
function to add n binary strings.
Driver code"
Solution in Python:
assistant
#Here is code to add n binary strings and the other steps required.
 def addBinaryUtil ( a , b ) :
result = " " ;
s = 0 ;
	i = len ( a ) - 1 ;
	j = len ( b ) - 1 ;
	while ( i >= 0 or j >= 0 or s == 1 ) :
		s += ( ord ( a [ i ] ) - ord ( '0' ) ) if ( i >= 0 ) else 0 ;
		s += ( ord ( b [ j ] ) - ord ( '0' ) ) if ( j >= 0 ) else 0 ;
		result = chr ( s % 2 + ord ( '0' ) ) + result ;
		s //= 2 ;
		i -= 1 ;
		j -= 1 ;
	return result ;
def addBinary ( arr , n ) :
	result = " " ;
	for i in range ( n ) :
		result = addBinaryUtil ( result , arr [ i ] ) ;
	return result ;
arr = [ "1" , "10" , "11" ] ;
n = len ( arr ) ;
print ( addBinary ( arr , n ) ) ;