':type nums: List[int]
:rtype: int'

def majorityElement(self, nums):

    (idx, cnt) = (0, 1)
    for i in xrange(1, len(nums)):
        if (nums[idx] == nums[i]):
            cnt += 1
        else:
            cnt -= 1
            if (cnt == 0):
                idx = i
                cnt = 1
    return nums[idx]
