class Solution {
public:
int majorityElement(vector<int>& nums) {
int len = nums.size();
map<int,int> result;
for(int i=0;i<len;i++){
result[nums[i]]++;
if(result[nums[i]] > len/2){
return nums[i];
}
}
}
};