Ctrl K

Combined Score Table

Easy
Two judges kept separate score tables, left and right. Each row is a pair [id, points]: a player number and the points that judge awarded. Within each table player numbers are distinct and strictly increasing. Combine the tables into one. Every player who appears in at least one table gets exactly one row [id, total], where total is the sum of their points from both judges (a player missing from a table counts as zero there). The result must also be sorted by id in ascending order.
Example 1
left=[[2, 10], [5, 7]], right=[[1, 4], [2, 6], [9, 3]] → [[1, 4], [2, 16], [5, 7], [9, 3]]

Player 2 is in both tables: 10 + 6 = 16. Everyone else appears once and is copied as is.

Example 2
left=[[3, 1]], right=[[3, 999]] → [[3, 1000]]

The same player in both, so the points add up: [[3, 1000]].

Example 3
left=[[4, 8], [6, 2]], right=[[1, 5]] → [[1, 5], [4, 8], [6, 2]]
Constraints
  • 1 ≤ len(left), len(right) ≤ 200
  • Each row is a pair [id, points]
  • 1 ≤ id, points ≤ 1000
  • Within each table id values are strictly increasing
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValues in Both Lists EasyShared Values With Repeats EasyTwice as Much EasyEvenly Spaced Triples EasyA Number and Its Opposite Easy
loading Python…
Input
left=[[2, 10], [5, 7]], right=[[1, 4], [2, 6], [9, 3]]
Expected
[[1, 4], [2, 16], [5, 7], [9, 3]]

Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.