Skip to content

Commit efd44e5

Browse files
add 3238
1 parent e3380d3 commit efd44e5

File tree

2 files changed

+32
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+32
-0
lines changed

Diff for: paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
3+
| 3238 | [Find the Number of Winning Players](https://leetcode.com/problems/find-the-number-of-winning-players/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3238.java) | | Easy |
34
| 3237 | [Alt and Tab Simulation](https://leetcode.com/problems/alt-and-tab-simulation/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3237.java) | | Medium |
45
| 3234 | [Count the Number of Substrings With Dominant Ones](https://leetcode.com/problems/count-the-number-of-substrings-with-dominant-ones/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3234.java) | | Medium | Sliding Window
56
| 3233 | [Find the Count of Numbers Which Are Not Special](https://leetcode.com/problems/find-the-count-of-numbers-which-are-not-special/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3233.java) | | Medium | Math
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class _3238 {
7+
public static class Solution1 {
8+
public int winningPlayerCount(int n, int[][] pick) {
9+
int winners = 0;
10+
Map<Integer, int[]> map = new HashMap<>();
11+
for (int[] p : pick) {
12+
int player = p[0];
13+
int color = p[1];
14+
int[] colors = map.getOrDefault(player, new int[11]);
15+
colors[color]++;
16+
map.put(player, colors);
17+
}
18+
for (Map.Entry<Integer, int[]> entry : map.entrySet()) {
19+
int player = entry.getKey();
20+
int[] colors = entry.getValue();
21+
for (int c : colors) {
22+
if (c >= player + 1) {
23+
winners++;
24+
break;
25+
}
26+
}
27+
}
28+
return winners;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)