You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//return the elem that has the majority count in the array
intmajorE(int low, int hi,vector<int>& arr ){
if(hi==low)
return arr[low];
int mid = low+(hi-low)/2;
int left = majorE(low,mid,arr );
int right = majorE(mid+1, hi,arr );
if(left==right)
return left;
else{
//count(...) Returns the number of elements in the range [first,last) that compare equal to val. => I think its better to write this function by myself...as I may forget to add 1 at the second arguement