题解 | #合并表记录#
合并表记录
http://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201
while(line = readline()) {
var rowCount = parseInt(line)
var map = {}
var row
while(row = readline()) {
var rowArr = row.split(' ')
if (map[rowArr[0]] === undefined) {
map[rowArr[0]] = 0
}
map[rowArr[0]] += parseInt(rowArr[1])
}
Object.keys(map).sort(
function(a, b) {
return a - b
}
).forEach(key => {
console.log(key + ' ' + map[key])
})
}