<jupyter_start><jupyter_text>Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always exist in the array.Example 1:Input: [3,2,3]Output: 3Example 2:Input: [2,2,1,1,1,2,2]Output: 2discussion 1: https://leetcode.com/problems/majority-element/discuss/136161/O(1)-Space-Python-Solution:-BoyerMoore-majority-vote-algorithm<jupyter_code>def majorityElement(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        major=nums[0]
        cnt=1
        
        for i in range(1,len(nums)):
            if cnt==0:
                major=nums[i]
            if nums[i]==major:
                cnt+=1
            else:
                cnt-=1
        return major<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1148491879350348, 'fraction_numerical': 0.033642691415313224, 'mean_word_length': 2.4246031746031744, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '370698', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 302, 'n_tokens_neox': 281, 'n_words': 71, 'path': '169. Majority Element.ipynb', 'repo_name': 'kkoo1122/Leetcode_Practice', 'size': '862'}