Given a tournament of m games, each played between two players with a known winner and margin, answer queries of the form: given two players, who won more matches? Asked in the pair programming round 2 stage. Part 1 is a simple hashmap solution returning -1 on a tie. Part 2 breaks ties transitively: if A and B never played but A beat C and C beat B, A wins, requiring DFS from both sides. Reported follow-ups: On a tie, resolve transitively via DFS from both players.
Use the games and match_queries tables for Part 1.
query_id, player_a, player_b, and result.1 when player_a has more wins, 2 when player_b has more wins, and -1 on a tie.query_id ascending.| Column | Type | Description |
|---|---|---|
| game_idPK | INT | Unique game identifier |
| player_one | INT | Identifier of the first player |
| player_two | INT | Identifier of the second player |
| winner | INT | Identifier of the game winner |
| margin | INT | Winning margin |
| Column | Type | Description |
|---|---|---|
| query_idPK | INT | Unique comparison query identifier |
| player_a | INT | First player being compared |
| player_b | INT | Second player being compared |