Skip to content

Commit

Permalink
add 3238
Browse files Browse the repository at this point in the history
  • Loading branch information
fishercoder1534 committed Aug 3, 2024
1 parent e3380d3 commit efd44e5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions paginated_contents/algorithms/4th_thousand/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
| # | Title | Solutions | Video | Difficulty | Tag
|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
| 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 |
| 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 |
| 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
| 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
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/fishercoder/solutions/fourththousand/_3238.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}
}
}

0 comments on commit efd44e5

Please sign in to comment.