players people numbered from zero. Each of them draws colored chips from a bag; an entry draws[i] = [p, c] means player p drew a chip of color c.
The higher a player's number, the tougher their winning condition: player p wins if at least p + 1 of their chips share one color. So player 0 only has to draw any chip at all, while player 2 needs three chips of the same color.
Return how many players won (there may be several winners, or none).players=3, draws=[[2, 5], [0, 7], [2, 5], [1, 3], [2, 5]] → 2
Player 0 drew something, so they win. Player 1 needs two chips of one color but has just one. Player 2 needs three of one color and has exactly three of color 5. Two winners.
players=4, draws=[[3, 1], [3, 2], [3, 3], [3, 4]] → 0
Player 3 drew four chips, all of different colors, and nobody else drew anything.
players=2, draws=[[1, 0], [1, 0]] → 1
players=3, draws=[[2, 5], [0, 7], [2, 5], [1, 3], [2, 5]]
2
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.