# Untitled

unknown
plain_text
a year ago
1.4 kB
2
Indexable
Never
```class Solution(object):
def isMajorityElement(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: bool
"""
if len(nums) == 1:
return False
left = 0
right = len(nums) - 1

target1 = -1
target2 = -1

while left <= right:
mid = left + (right - left) // 2
if nums[mid] == target:
target1 = mid
right = mid - 1
elif nums[mid] < target:
left = mid + 1
else:
right = mid -1

left = target1
right = len(nums) - 1

while left <= right:
mid = left + (right - left) // 2
if nums[mid] == target:
target2 = mid
left = mid + 1
elif nums[mid] < target:
left = mid + 1
else:
right = mid -1

print(target1, target2)

return (target2 - target1) + 1 > len(nums)/2

#####     Approach Using Hash Map/Dict

#         hashMap = defaultdict(int)
#         for i in nums:
#             hashMap[i] += 1

#         print(hashMap[target])
#         if hashMap[target] > len(nums)/2:
#             return True
#         else:
#             return False
```