Skip to content

Practice Best Poker Hand

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2347
LeetCode Problem

Best Poker Hand

Problem Statement

Classify the five cards in ranks and suits using only these categories, in descending priority: Flush for five matching suits; Three of a Kind for at least three matching ranks; Pair for at least two matching ranks; otherwise High Card. Return the category name with exactly that capitalization.

Source: Best Poker Hand on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
ranks = [13,2,3,1,9], suits = ["a","a","a","a","a"]
Output
"Flush"

# Example 2

Input
ranks = [4,4,2,4,4], suits = ["d","a","a","b","c"]
Output
"Three of a Kind"

# Example 3

Input
ranks = [10,10,2,12,9], suits = ["a","b","c","a","d"]
Output
"Pair"

Constraints

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

Related LeetCode Problems

Practice more problems similar to Best Poker Hand.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.