题解 | #微信红包#简单 map 拿捏
微信红包
https://www.nowcoder.com/practice/fbcf95ed620f42a88be24eb2cd57ec54
int getValue(vector<int> gifts, int n) {
if(gifts.empty() || n==0)
return 0;
map<int,int> m;
map<int,int>::iterator it;
for(auto& e:gifts)
{
m[e]++;
}
int count = 0;
int val = 0;
for(it = m.begin(); it != m.end(); it++)
{
if(it->second > n/2)
{
return it->first;
}
}
return 0;
}
};

