```
class Solution {
public:
int majorityElement(vector<int>& nums)
{
map<int, int> cnt;
for(int i=0; i < nums.size(); i++)
cnt[ nums[i] ]++;
int n = nums.size();
for(map<int, int>::iterator iter = cnt.begin(); iter != cnt.end(); iter++)
if( iter->second > n/2 )
return iter->first;
}
};
```