借助set
注意:count = map.get(numbers[i]) || 0;
function MoreThanHalfNum_Solution(numbers)
{
let map = new Map();
let count;
for(let i=0; i<numbers.length; i++){
count = map.get(numbers[i]) || 0;
map.set(numbers[i],count+1);
}
for(let i=0; i<numbers.length; i++)
if(map.get(numbers[i]) > numbers.length/2)
return numbers[i];
}
module.exports = {
MoreThanHalfNum_Solution : MoreThanHalfNum_Solution
};