-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path2347.cpp
More file actions
29 lines (26 loc) · 719 Bytes
/
2347.cpp
File metadata and controls
29 lines (26 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Solution {
public:
string bestHand(vector<int>& ranks, vector<char>& suits) {
// Flush
char c = suits[0];
bool flag = true;
for (auto& ch : suits) {
if (ch != c) {
flag = false;
break;
}
}
if (flag) return "Flush";
vector<int> counts(14, 0);
for (auto& rank : ranks) {
counts[rank]++;
}
int maxCount = 0;
for (int i = 0; i < 14; ++i) {
maxCount = max(maxCount, counts[i]);
}
if (maxCount >= 3) return "Three of a Kind";
if (maxCount >= 2) return "Pair";
return "High Card";
}
};