1150. Check If a Number Is Majority Element in a Sorted Array

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1150

class Solution:
    def isMajorityElement(self, nums: List[int], target: int) -> bool:
        left = bisect_left(nums, target)
        right = left + len(nums) // 2
        return right < len(nums) and nums[right] == target