class Solution {
public:
int majorityElement(vector& nums) {
int res=nums[0];
int count=1;
int mid=0;
if(nums.size()%2==0)
mid=nums.size()/2;
if(nums.size()%2==1)
mid=nums.size()/2+1;
for(int i=0;i<nums.size();i++)
{
count=1;
for(int j=i+1;j<nums.size();j++)
{
if(nums[i]==nums[j])
count++;
if(count>=mid)
res=nums[i];
}
}
return res;
}
};