题解 | #记票统计#
记票统计
http://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
let str; while(str = readline()){ let people = readline(); let laji = readline(); let piao = readline(); let sum=0,res={}; let pArr = people.split(' '); let piArr = piao.split(' '); for(let v in piArr){ if(pArr.includes(piArr[v])){ if(res[piArr[v]]){ res[piArr[v]]++; }else{ res[piArr[v]] = 1; } }else{ sum++; } } for(let v of pArr){ if(res[v]){ console.log(v+' :'+' '+res[v]); }else{ console.log(v+' :'+' 0'); } } console.log('Invalid :'+' '+sum); }