数组中超过一半的数
int NumberAppearMoreThanOneHalf(vactor
{
if (numbers.empty==0)
{
return 0;
}
map<int, int> m;
for(int i=0; i<numbers.size(); ++i)
{
++m[numbers[i]];
}
for(auto member:m)
{
int size = numbers.size();
if(member.second > size/2)
{
return member.first;
}
}
return 0;
}
无欲则刚 关心则乱