We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 59bd38a commit 430d8faCopy full SHA for 430d8fa
2347. Best Poker Hand.cpp
@@ -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