In this challenge, you have to establish which kind of Poker combination is present in a deck of five cards. Every card is a string containing the card value (with the upper-case initial for face-cards) and the lower-case initial for suits, as in the examples below:
- "Ah" ➞ Ace of hearts
- "Ks" ➞ King of spades
- "3d" ➞ Three of diamonds
- "Qc" ➞ Queen of clubs
In Poker there 10 different combinations, but for the sake of this exercise we're going to simplify and use only 4 combinations Here's the list, in order of importance:
| Name | Description |
|---|---|
| Royal Flush | A, K, Q, J, 10, all with the same suit. |
| Four of a Kind | Four cards of the same rank. |
| Pair | Two cards of the same rank. |
| High Card | No other valid combination. |
Given an array hand containing five strings being the cards, implement a function that returns a string with the name of the highest combination obtained, accordingly to the table above.
Examples
pokerHandRanking(["10h", "Jh", "Qh", "Ah", "Kh"]) ➞ "Royal Flush"
pokerHandRanking(["3h", "5h", "Qs", "9h", "Ad"]) ➞ "High Card"
pokerHandRanking(["10s", "10c", "8d", "10d", "10h"]) ➞ "Four of a Kind"
Code
using namespace std;
string pokerHandRanking(vector<string> hand) {
}