Ctrl K

Strongest Card Combo

Easy
In a card game you hold five cards. Card i has value ranks[i] and suit suits[i]. The combinations, from strongest to weakest, are: 1. "Flush": all five cards share a suit; 2. "Three of a Kind": three cards with the same value; 3. "Pair": two cards with the same value; 4. "High Card": any single card. Return the name of the strongest combination you can form from these cards, spelled exactly as above (case matters).
Example 1
ranks=[2, 8, 11, 5, 13], suits=["c", "c", "c", "c", "c"] → 'Flush'

All five cards share suit c, so it is a "Flush", the top combination.

Example 2
ranks=[9, 3, 9, 9, 6], suits=["a", "b", "c", "d", "a"] → 'Three of a Kind'

Three nines make "Three of a Kind"; a pair is also there, but three of a kind ranks higher.

Example 3
ranks=[1, 4, 7, 10, 12], suits=["a", "b", "a", "d", "c"] → 'High Card'

All values differ and the suits are mixed, so only "High Card" remains.

Constraints
  • ranks.length = suits.length = 5
  • 1 ≤ ranks[i] ≤ 13
  • suits[i] is one of a, b, c, d
  • No two cards share both value and suit
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Candidate With Most Votes EasyValues One Apart EasyEven Piles of Cards EasyMatching Domino Tiles EasyWords From Letter Tiles Easy
loading Python…
Input
ranks=[2, 8, 11, 5, 13], suits=["c", "c", "c", "c", "c"]
Expected
'Flush'

Run checks the first 3 tests in your browser. Submit checks all 51 tests on the server, hidden ones included.