Tap here to switch tabs
Problem
Submissions

Problem: Best Poker Hand

med
30 min
Try to solve the Best Poker Hand problem.

Statement

You are given an integer array ranks and a character array suits. There are 55 cards where the iextthi^{ ext{th}} card has a rank of ranks[i] and a suit of suits[i].

Return a string representing the highest ranking poker hand that can be formed from the given cards.

The possible poker hands, ordered from best to worst, are:

11. "Flush": 55 cards of the exact same suit.
22. "Three of a Kind": 33 cards of the exact same rank.
33. "Pair": 22 cards of the exact same rank.
44. "High Card": Any single card that does not meet the criteria of the hands above.

Note: The returned hand must be the highest ranking hand among all valid hands that can be formed.

Constraints:

  • ranks.length ==== suits.length ==5== 5

  • 1≤1 \leq ranks[i] ≤13\leq 13

  • 'a' ≤\leq suits[i] ≤\leq 'd'

  • No two cards have the same rank and suit.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Best Poker Hand

med
30 min
Try to solve the Best Poker Hand problem.

Statement

You are given an integer array ranks and a character array suits. There are 55 cards where the iextthi^{ ext{th}} card has a rank of ranks[i] and a suit of suits[i].

Return a string representing the highest ranking poker hand that can be formed from the given cards.

The possible poker hands, ordered from best to worst, are:

11. "Flush": 55 cards of the exact same suit.
22. "Three of a Kind": 33 cards of the exact same rank.
33. "Pair": 22 cards of the exact same rank.
44. "High Card": Any single card that does not meet the criteria of the hands above.

Note: The returned hand must be the highest ranking hand among all valid hands that can be formed.

Constraints:

  • ranks.length ==== suits.length ==5== 5

  • 1≤1 \leq ranks[i] ≤13\leq 13

  • 'a' ≤\leq suits[i] ≤\leq 'd'

  • No two cards have the same rank and suit.