题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
let num =readline(); let obj = {}; for(var i = 0;i < num;i++){ let arr = readline().split(' '); if(!obj[arr[0]]){ obj[arr[0]] = arr[1]; }else{ obj[arr[0]] =Number(obj[arr[0]]) + Number(arr[1]); } } for(let a in obj){ console.log(a + ' ' +obj[a]); }