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

Обновлено: 2024-03-12
1 мин
[]

Содержание

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