Block 面试题:根据比赛结果判断两位玩家谁表现更好(锦标赛评分问题)

47次阅读
没有评论

Say we have a tournament of some sort. It doesn’t matter what the tournament is for. All we need to know is:

  • Each game in the tournament is 1 vs 1
  • At the end of a game, each player has a non-negative score (0 or higher)
  • Usual rule: higher score wins, but ties are possible
  • To keep things fair, at the end of the tournament, everybody has played the same number of games

Given the results of a tournament and the IDs of two players,
we’d like to know which of those two players did better in the overall tournament.

Game results are in the format:

{player1, score1, player2, score2}

Example tournamentResults:

{0,  9,  2,  7},
{1, 11, 14,  2},
{3,  6,  7,  5},
{4, 10,  8,  7},
{5, 12, 12, 12},
{9,  8, 10,  3},
{11,11, 13, 12},
{15, 5,  6, 15},
{0,  5, 14,  8},
{1, 11,  2, 13},
{3,  7, 15,  8},
{4,  7, 10,  3},
{5,  8, 13,  8},
{6,  0,  7,  5},
{8,  9, 12,  6},
{9, 11, 11,  9}

Rule for tie-breaks:

If Alice and Bob finish with the same record,
but Alice played Bob and won,
then Alice is ranked higher.


  • 统计每位玩家的总胜场 / 负场。
  • 比较两人胜场数,多者更强。
  • 若胜负相同,查看两人直接对战,直接胜者排名更高。

VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 Block、Amazon、Apple、Google 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。

正文完
 0