题解 | #合并表记录#
合并表记录
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 let arr = []; while ((line = await readline())) { let str = line.split(" "); if (str[1]) { let index = parseInt(str[0]); let value = parseInt(str[1]); if (arr[index]) { arr[index] += value; } else { arr[index] = value; } } } arr.forEach((value,index) =>{ console.log(index,value) }) })();