You are given an integer array ranks and a character array suits. You have 5 cards where the ith card has a rank of ranks[i] and a suit of suits[i].

The following are the types of poker hands you can make from best to worst:


	"Flush": Five cards of the same suit.
	"Three of a Kind": Three cards of the same rank.
	"Pair": Two cards of the same rank.
	"High Card": Any single card.


Return a string representing the best type of poker hand you can make with the given cards.

Note that the return values are case-sensitive.

&nbsp;
Example 1:

Input: ranks = [13,2,3,1,9], suits = ["a","a","a","a","a"]
Output: "Flush"
Explanation: The hand with all the cards consists of 5 cards with the same suit, so we have a "Flush".


Example 2:

Input: ranks = [4,4,2,4,4], suits = ["d","a","a","b","c"]
Output: "Three of a Kind"
Explanation: The hand with the first, second, and fourth card consists of 3 cards with the same rank, so we have a "Three of a Kind".
Note that we could also make a "Pair" hand but "Three of a Kind" is a better hand.
Also note that other cards could be used to make the "Three of a Kind" hand.

Example 3:

Input: ranks = [10,10,2,12,9], suits = ["a","b","c","a","d"]
Output: "Pair"
Explanation: The hand with the first and second card consists of 2 cards with the same rank, so we have a "Pair".
Note that we cannot make a "Flush" or a "Three of a Kind".


&nbsp;
Constraints:


	ranks.length == suits.length == 5
	1 &lt;= ranks[i] &lt;= 13
	'a' &lt;= suits[i] &lt;= 'd'
	No two cards have the same rank and suit.


class Solution:
    def bestHand(self, ranks: List[int], suits: List[str]) -> str:
        s={}
        for i in suits:
            if i in s:
                s[i]+=1
                if s[i]==5:
                    return 'Flush'
            else:
                s[i]=1
        r={}
        max_ = 0
        for i in ranks:
            if i in r:
                r[i]+=1
                max_=max(max_,r[i])
            else:
                r[i]=1
        if max_>=3:
            return "Three of a Kind"
        elif max_==2:
            return "Pair"
        else:
            return "High Card"
class Solution {
    public String bestHand(int[] ranks, char[] suits) {
    int max = 0;
    int card = 0;
    char ch = suits[0];
    int[] arr = new int[14];
    for(int i = 0; i < 5; i++){
        arr[ranks[i]]++;
        max = Math.max(max,arr[ranks[i]]);
        if(suits[i] == ch) card++;
    }
        if(card == 5) return "Flush";
     return max >= 3 ? "Three of a Kind":(max == 2 ? "Pair" : "High Card");
    }
}
class Solution {
public:
    string bestHand(vector<int>& ranks, vector<char>& suits) {
        map<int, int> m1;
        int mn = INT_MIN;
        int all_same = count(begin(suits), end(suits), suits[0]);
        int n = ranks.size();
        for (int i = 0; i < n; i++) {
            m1[ranks[i]]++;
            mn = max(mn, m1[ranks[i]]);
        }
        if (all_same == n)     return "Flush";
        if (mn >= 3)      return "Three of a Kind";
        if (mn == 2)      return "Pair";
        return "High Card";
    }
};
var bestHand = function(ranks, suits) {
    let suitsMap = {}
    for (let i=0; i<suits.length; i++) {
        if (suitsMap[suits[i]]) {
            suitsMap[suits[i]]++;
        } else {
            suitsMap[suits[i]] = 1;
        }
    }
    if (Object.keys(suitsMap).length === 1) return "Flush";
    let pair = false;
    let ranksMap = {};
    for (let i=0; i<ranks.length; i++) {
        if (ranksMap[ranks[i]]) {
            ranksMap[ranks[i]]++;
            if (ranksMap[ranks[i]] >= 3) return "Three of a Kind";
        } else {
            ranksMap[ranks[i]] = 1;
        }
    }
    if (Object.keys(ranksMap).length === 5) return "High Card";
    return "Pair";
};
Best Poker Hand