from typing import List


class Solution:
    def majorityElement(self, nums: List[int]) -> int:
        majority_limit = len(nums) / 2
        count_store = {}
        for elem in nums:
            try:
                count_store[elem] += 1
            except KeyError:
                count_store[elem] = 1
            if count_store[elem] > majority_limit:
                return elem


sl1 = Solution()
sl2 = Solution()
print(sl1.majorityElement(nums=[3, 2, 3]))
print(sl1.majorityElement(nums=[2, 2, 1, 1, 1, 2, 2]))
