3238. Find the Number of Winning Players | Dart Solution | Time O(n+p) | Space O(n+p)
ApproachThe solution uses a multi-step process to count winning players:

Initialize data structures:

Create a list of empty lists for each player's picks
Crea
## Approach

The solution uses a multi-step process to count winning players:

1. Initialize data structures:
   - Create a list of empty lists for each player's picks
   - Create a set to track winning players

2. Organize picks by player:
   - Iterate through pick array
   - Add each ball color to corresponding player's list

3. Analyze each player's picks:
   - Skip players with no picks
   - For each player with picks:
     - Create frequency map of ball colors
     - Track count of each color
     - Mark player as winner if any color count ≥ player's index + 1

4. Return count of winners:
   - Return size of winner set

This approach efficiently organizes and analyzes the data while maintaining unique winners.

## Complexity

- Time complexity: $$O(n + p)$$
  Where n is the number of players and p is the number of picks. We need one pass to organize picks and another pass to analyze each player's picks.

- Space complexity: $$O(n + p)$$
  We store:
  - List of lists for players' picks (O(p))
  - Set for winners (O(n))
  - Temporary maps for ball color frequencies (O(1) for each player)

# Code
```dart []
class Solution {
  int winningPlayerCount(int n, List<List<int>> pick) {
    List<List<int>> players = List.generate(n, (int index) => []);
    Set<int> winner = {};
    print(players);
    for (var e in pick) {
      players[e[0]].add(e[1]);
    }
    print(players);
    for (var i = 0; i < players.length; i++) {
      if (players[i].isEmpty) {
        continue;
      } else {
        Map<int, int> balls = {};
        for (var ballColour in players[i]) {
          balls[ballColour] =
              balls[ballColour] == null ? 1 : balls[ballColour]! + 1;
          if (balls[ballColour]! >= i + 1) {
            winner.add(i);
          }
        }
      }
    }
    return winner.length;
  }
}

```
['Dart']