Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b0baf71

Browse files
add 2347
1 parent f4c6b11 commit b0baf71

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|-------------
11-
| 2341 |[Maximum Number of Pairs in Array](https://leetcode.com/problems/maximum-number-of-pairs-in-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2341.java) || Easy ||
11+
| 2347 |[Maximum Number of Pairs in Array](https://leetcode.com/problems/best-poker-hand/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2347.java) || Easy ||
12+
| 2341 |[Maximum Number of Pairs in Array](https://leetcode.com/problems/maximum-number-of-pairs-in-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2341.java) || Easy ||
1213
| 2335 |[Minimum Amount of Time to Fill Cups](https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2335.java) || Easy ||
1314
| 2331 |[Evaluate Boolean Binary Tree](https://leetcode.com/problems/evaluate-boolean-binary-tree/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2331.java) || Easy ||
1415
| 2326 |[Spiral Matrix IV](https://leetcode.com/problems/spiral-matrix-iv/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2326.java) || Medium ||
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.HashMap;
4+
import java.util.HashSet;
5+
import java.util.Map;
6+
import java.util.Set;
7+
8+
public class _2347 {
9+
public static class Solution1 {
10+
public String bestHand(int[] ranks, char[] suits) {
11+
Set<Character> set = new HashSet<>();
12+
for (char c : suits) {
13+
set.add(c);
14+
}
15+
if (set.size() == 1) {
16+
return "Flush";
17+
}
18+
Map<Integer, Integer> map = new HashMap<>();
19+
for (int i : ranks) {
20+
map.put(i, map.getOrDefault(i, 0) + 1);
21+
}
22+
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
23+
if (entry.getValue() >= 3) {
24+
return "Three of a Kind";
25+
}
26+
}
27+
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
28+
if (entry.getValue() == 2) {
29+
return "Pair";
30+
}
31+
}
32+
return "High Card";
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)