Skip to content

Latest commit

 

History

History

169. Majority Element

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Solution

class Solution:
    def majorityElement(self, nums):
        count = 0
        for num in nums:
            if count == 0:
                candidate = num
            count += (1 if num == candidate else -1)
        return candidate