class Solution(object):
def majorityElement(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums)==1:
return nums[0]
else:
n=nums[0]
count=1
for i in range(1,len(nums)):
if nums[i]==n:
count+=1
else:
if count==0:
n=nums[i]
count=1
else:
count-=1
return n