The problem is tagged with Bit Manipulation. So I tried to convert the solution of Java version (count bits) into python one. However, I got unexpected result.

Output:

2147483648

Expected:

-2147483648

The problem might be about the sign bit. Can anyone share how to solve the sign bit problem in python? That will be much appreciated.

{

```
class Solution:
def majorityElement(self, num):
ones, zeros, result = 0, 0, 0
for digit in range(32):
ones = 0; zeros = 0
for element in num:
if ((element >> digit) & 1) == 1:
ones += 1
else:
zeros += 1
if ones > zeros:
result |= 1 << digit
return result
```

}