๐ Gaming Tournament Analysis
You're organizing a competitive ball-picking game tournament with n players, numbered from 0 to n-1. Each player picks colored balls throughout the game, and their picks are recorded in a 2D array pick where pick[i] = [player, color] represents that player picked a ball of color.
The winning condition is progressive - higher numbered players need more balls of the same color to win:
- Player 0 wins if they pick any ball at all (โฅ 1 ball of any color)
- Player 1 wins if they pick at least 2 balls of the same color
- Player i wins if they pick at least (i + 1) balls of the same color
Goal: Return the total number of players who meet their winning condition. Note that multiple players can win simultaneously!
Example: If Player 2 picks 3 red balls, they win because 3 โฅ (2 + 1). If Player 0 picks 1 blue ball, they also win because 1 โฅ (0 + 1).
Input & Output
Visualization
Time & Space Complexity
Single pass through m picks, each hash map operation is O(1) average case
Hash map storing up to k colors for each of n players, plus winners set
Constraints
- 2 โค n โค 10
- 0 โค picks.length โค 100
- picks[i].length == 2
- 0 โค xi < n
- 0 โค yi โค 10
- Each pick represents one ball selection