Skip to content

Commit 430d8fa

Browse files
committed
Solution as on 23-07-2022 11:00 pm
1 parent 59bd38a commit 430d8fa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

2347. Best Poker Hand.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// 2347.✅ Best Poker Hand
2+
3+
class Solution
4+
{
5+
public:
6+
string bestHand(vector<int> &ranks, vector<char> &suits)
7+
{
8+
map<int, int> r;
9+
map<char, int> s;
10+
11+
for (auto itr : ranks)
12+
++r[itr];
13+
for (auto itr : suits)
14+
++s[itr];
15+
16+
if (s.size() == 1)
17+
return "Flush";
18+
int mr = 1;
19+
for (auto itr : r)
20+
{
21+
if (itr.second > mr)
22+
mr = itr.second;
23+
}
24+
// cout<< mr<<endl;
25+
if (mr >= 3 && mr < 5)
26+
return "Three of a Kind";
27+
else if (mr == 2)
28+
return "Pair";
29+
30+
return "High Card";
31+
}
32+
};

0 commit comments

Comments
 (0)