不要考这种题…
class Solution {
public:
int moreThanHalfNum_Solution(vector<int>& nums) {
int n = nums.size();
unordered_map<int,int>hash;
for(int i = 0 ; i < n ; i ++)
{
hash[nums[i]]++;
if(hash[nums[i]]>n/2)return nums[i];
}
return -1;
}
};