human
Find the Majority Element | Set 3 ( Bit Magic ) | .
Number of bits in the integer.
Variable to calculate majority element.
Loop to iterate through all the bits of number.
Loop to iterate through all elements in array to count the total set bit at position i from right.
If the total set bits exceeds n / 2 , this bit should be present in majority Element ..
iterate through array get the count of candidate majority element.
Verify if the count exceeds n / 2.
Driver Code"
How can the above be solved in Python?

=====
Can you provide a code to find the Majority Element and the other steps required?
assistant
#Here is code to find the Majority Element and the other steps required.
 def findMajority ( arr , n ) :
	Len = 32
	number = 0
	for i in range ( Len ) :
		count = 0
		for j in range ( n ) :
			if ( arr [ j ] & ( 1 << i ) ) :
				count += 1
		if ( count > ( n // 2 ) ) :
			number += ( 1 << i )
	count = 0
	for i in range ( n ) :
		if ( arr [ i ] == number ) :
			count += 1
	if ( count > ( n // 2 ) ) :
		print ( number )
	else :
		print ( " Majority ▁ Element ▁ Not ▁ Present " )
arr = [ 3 , 3 , 4 , 2 , 4 , 4 , 2 , 4 , 4 ]
n = len ( arr )
findMajority ( arr , n )