题解 | #合并表记录#
合并表记录
https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
// Write your code here
while(line = await readline()){
let length = parseInt(line);
let obj = {};
for (let i = 0; i < length; i++) {
let [k,v] = (await readline()).split(" ");
if (obj[k]) {
obj[k] += parseInt(v);
} else {
obj[k] = parseInt(v)
}
}
for (const key in obj) {
console.log(key + " " + obj[key]);
}
}
}()

