3519. Find the Number of Winning Players
My accepted Python solution to LeetCode problem 3519, Find the Number of Winning Players, running in 5ms.
- Difficulty: Easy
- Python
- Runtime 5ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 5ms, memory 17.3MB, accepted 2025-12-31.
class Solution:
def winningPlayerCount(self, n: int, pick: List[List[int]]) -> int:
from collections import defaultdict
# Count balls of each color for each player
# player_colors[player][color] = count
player_colors = defaultdict(lambda: defaultdict(int))
for player, color in pick:
player_colors[player][color] += 1
# Count winning players
winners = 0
for player in range(n):
# Player i wins if they have strictly more than i balls of same color
for color, count in player_colors[player].items():
if count > player:
winners += 1
break
return winners