human
Can you provide a code to bitwise OR of N binary strings and the other steps required given the following:
Bitwise OR of N binary strings | Function to return the bitwise OR of all the binary strings.
Get max size and reverse each string Since we have to perform OR operation on bits from right to left Reversing the string will make it easier to perform operation from left to right.
Add 0 s to the end of strings if needed.
Perform OR operation on each bit.
Reverse the resultant string to get the final string.
Return the final string.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to bitwise OR of N binary strings and the other steps required.
 def strBitwiseOR ( arr , n ) :
	res = " "
	max_size = - ( 2 ** 32 )
	for i in range ( n ) :
		max_size = max ( max_size , len ( arr [ i ] ) )
		arr [ i ] = arr [ i ] [ : : - 1 ]
	for i in range ( n ) :
		s = " "
		for j in range ( max_size - len ( arr [ i ] ) ) :
			s += '0'
		arr [ i ] = arr [ i ] + s
	for i in range ( max_size ) :
		curr_bit = 0
		for j in range ( n ) :
			curr_bit = curr_bit | ord ( arr [ j ] [ i ] )
		res += chr ( curr_bit )
	res = res [ : : - 1 ]
	return res
arr = [ "10" , "11" , "1000001" ]
n = len ( arr )
print ( strBitwiseOR ( arr , n ) )