Check if a number is majority element in the sorted array

input:nums=[2,4,5,5,5,5,5,6,6], target=5return True
low=0
high=len(nums-1)
n=len(nums)//2
while(low<high):
mid=(low+high)/2
if(nums[left]<target):
low=mid+1
else:
high=mid
return (low + n/2<len(nums) and nums[low + n/2]==target)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dhanarajappu

Dhanarajappu

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.