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; } };