题解 | #记票统计#
记票统计
http://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
const trueTotal = parseInt( readline() ) const trueArr = readline().split(" ") const total = parseInt( readline() ) const totalArr = readline().split(" ") const obj = {} trueArr.forEach( item => { obj[ item ] = 0 }) const falseArr = [] totalArr.forEach( item => { if( trueArr.indexOf( item ) > -1 ) { obj[item] += 1 }else { falseArr.push( item ) } }) Object.keys( obj ).forEach( key => { print(`${key} : ${obj[key]}`) }) print(`Invalid : ${falseArr.length}`)