-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoker Hand.cpp
More file actions
47 lines (30 loc) · 1.22 KB
/
Copy pathPoker Hand.cpp
File metadata and controls
47 lines (30 loc) · 1.22 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;
int main(void){
char rank, suit;
map<char,vector<char>> poker; // 1 key and many values A (2,3,4)
map<char, vector<char>>::iterator it ;
vector<int> result;
int n = 5;
while(n--){
cin >> rank >> suit;
it = poker.find(rank);
poker[rank].push_back(suit); // new or found entry will be added
}
//TRAVERSE A MAP
for(auto map_iter = poker.cbegin() ; map_iter != poker.cend() ; ++map_iter ){
//cout << map_iter->second.size() << endl; // number of values in the vector of a specific key
result.push_back(map_iter->second.size()); // push the size of vector into another vector
}
sort(result.begin(), result.end(), greater<int>());
cout << result[0] ;
// TO SHOW THE VALUES CORRESPONDING TO THE KEY
// for(auto map_iter = poker.cbegin() ; map_iter != poker.cend() ; ++map_iter){
//
// std::cout << "key: " << map_iter->first << " value: [ " ;
// for( auto vec_iter = map_iter->second.cbegin() ; vec_iter != map_iter->second.cend() ; ++vec_iter )
// std::cout << *vec_iter << " " ;
// std::cout << "]\n" ;
// }
return 0;
}