class Solution:
    def get_major(self, nums):
        candidate1, candidate2 = None, None
        count1, count2 = 0, 0

        for num in nums:
            if num == candidate1:
                count1 += 1
            elif num == candidate2:
                count2 += 1
            elif count1 == 0:
                candidate1 = num
                count1 = 1
            elif count2 == 0:
                candidate2 = num
                count2 = 1
            else:
                count1 -= 1
                count2 -= 1
        
        return [candidate for candidate in [candidate1, candidate2] if nums.count(candidate) > len(nums) // 3]

solution = Solution()
nums = [1,2,3,2,2,1,3,1,2,1]
print(solution.get_major(nums))