class Solution(object):
def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ n=len(nums) a=n/3 freq={} result=[] for i in nums: if i not in freq: freq[i]=1 else: freq[i] +=1 if freq[i]>a and i not in result: result.append(i) if result==[] and n<3: result=nums return result