-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3238.java
31 lines (29 loc) · 975 Bytes
/
_3238.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.fishercoder.solutions.fourththousand;
import java.util.HashMap;
import java.util.Map;
public class _3238 {
public static class Solution1 {
public int winningPlayerCount(int n, int[][] pick) {
int winners = 0;
Map<Integer, int[]> map = new HashMap<>();
for (int[] p : pick) {
int player = p[0];
int color = p[1];
int[] colors = map.getOrDefault(player, new int[11]);
colors[color]++;
map.put(player, colors);
}
for (Map.Entry<Integer, int[]> entry : map.entrySet()) {
int player = entry.getKey();
int[] colors = entry.getValue();
for (int c : colors) {
if (c >= player + 1) {
winners++;
break;
}
}
}
return winners;
}
}
}