3238. Find the Number of Winning Players Easy
1/**
2 * [3238] Find the Number of Winning Players
3 *
4 * You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player xi picked a ball of color yi.
5 * Player i wins the game if they pick strictly more than i balls of the same color. In other words,
6 *
7 * Player 0 wins if they pick any ball.
8 * Player 1 wins if they pick at least two balls of the same color.
9 * ...
10 * Player i wins if they pick at leasti + 1 balls of the same color.
11 *
12 * Return the number of players who win the game.
13 * Note that multiple players can win the game.
14 *
15 * <strong class="example">Example 1:
16 * <div class="example-block">
17 * Input: <span class="example-io">n = 4, pick = [[0,0],[1,0],[1,0],[2,1],[2,1],[2,0]]</span>
18 * Output: <span class="example-io">2</span>
19 * Explanation:
20 * Player 0 and player 1 win the game, while players 2 and 3 do not win.
21 * </div>
22 * <strong class="example">Example 2:
23 * <div class="example-block">
24 * Input: <span class="example-io">n = 5, pick = [[1,1],[1,2],[1,3],[1,4]]</span>
25 * Output: <span class="example-io">0</span>
26 * Explanation:
27 * No player wins the game.
28 * </div>
29 * <strong class="example">Example 3:
30 * <div class="example-block">
31 * Input: <span class="example-io">n = 5, pick = [[1,1],[2,4],[2,4],[2,4]]</span>
32 * Output: <span class="example-io">1</span>
33 * Explanation:
34 * Player 2 wins the game by picking 3 balls with color 4.
35 * </div>
36 *
37 * Constraints:
38 *
39 * 2 <= n <= 10
40 * 1 <= pick.length <= 100
41 * pick[i].length == 2
42 * 0 <= xi <= n - 1
43 * 0 <= yi <= 10
44 *
45 */
46pub struct Solution {}
47
48// problem: https://leetcode.com/problems/find-the-number-of-winning-players/
49// discuss: https://leetcode.com/problems/find-the-number-of-winning-players/discuss/?currentPage=1&orderBy=most_votes&query=
50
51// submission codes start here
52
53impl Solution {
54 pub fn winning_player_count(n: i32, pick: Vec<Vec<i32>>) -> i32 {
55 0
56 }
57}
58
59// submission codes end
60
61#[cfg(test)]
62mod tests {
63 use super::*;
64
65 #[test]
66 fn test_3238() {
67 }
68}
69
Back
© 2025 bowen.ge All Rights Reserved.