- 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
packagecom.fishercoder.solutions.fourththousand;
importjava.util.HashMap;
importjava.util.Map;
publicclass_3238 {
publicstaticclassSolution1 {
publicintwinningPlayerCount(intn, int[][] pick) {
intwinners = 0;
Map<Integer, int[]> map = newHashMap<>();
for (int[] p : pick) {
intplayer = p[0];
intcolor = p[1];
int[] colors = map.getOrDefault(player, newint[11]);
colors[color]++;
map.put(player, colors);
}
for (Map.Entry<Integer, int[]> entry : map.entrySet()) {
intplayer = entry.getKey();
int[] colors = entry.getValue();
for (intc : colors) {
if (c >= player + 1) {
winners++;
break;
}
}
}
returnwinners;
}
}
}