Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Best Poker Hand

XPChallenge Points: 10
levelLevel: Easy

You are given two arrays — ranks and suits — each of size 5, representing a hand of five playing cards.
The i-th card has:

  • rank = ranks[i]

  • suit = suits[i]

From these cards, your task is to determine the strongest possible poker hand according to the following hierarchy:

  1. Flush — All five cards share the same suit.

  2. Three of a Kind — Exactly three cards share the same rank.

  3. Pair — At least two cards share the same rank.

  4. High Card — None of the above.

Return the name of the highest-ranking hand you can make.
The output must match the exact capitalization shown.

Example 1:

Input: ranks = [7, 5, 9, 2, 7] suits = ["x","x","x","x","x"]

Output: "Flush"

Explanation:

All suits match → highest hand is a Flush.

Example 2:

Input: ranks = [8, 3, 8, 6, 8] suits = ["h","d","s","c","d"]

Output: "Three of a Kind"

Explanation:

The rank 8 appears three times.

Example 3:

Input: ranks = [2, 11, 5, 11, 9] suits = ["a","b","c","d","e"]

Output: "Pair"

Explanation:

The rank 11 appears twice.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result