Python Solution with O(n) time and O(1) space


#1
class Solution:
    # @param A : tuple of integers
    # @return an integer
    def majorityElement(self, A):
        majority = A[0]
        count = 1
        for i in A[1:]:
            if(count==0):
                majority= i
            if(majority==i):
                count+=1
            else:
                count-=1
        return majority