LeetCode solutions

2433. Best Poker Hand

My accepted Python solution to LeetCode problem 2433, Best Poker Hand, running in 2ms.

  • Difficulty: Easy
  • Python
  • Runtime 2ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 2ms, memory 17.3MB, accepted 2026-01-01.

python
class Solution:
    def bestHand(self, ranks: List[int], suits: List[str]) -> str:
        from collections import Counter
        if len(set(suits)) == 1:
            return "Flush"
        rank_counts = Counter(ranks)
        max_count = max(rank_counts.values())
        if max_count >= 3:
            return "Three of a Kind"
        if max_count == 2:
            return "Pair"
        return "High Card"

Source