FastPrepHigh-Card Pot Game
Problems/High-Card Pot Game

High-Card Pot Game

Affirm logoAffirm● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report describes round-robin dealing for two and then many players, with tied highest cards leaving the pot in play. Supplying the deck and returning won-card totals remove randomness while preserving every transition.

Deal the given deck to players players in round-robin order, starting with player 0. Each player's cards remain in deal order.

During a round, every player who still has a card reveals their next card and all revealed cards enter a shared pot. If exactly one player revealed the highest rank, that player wins every card currently in the pot and the pot becomes empty. If the highest rank is tied, the pot carries into the next round. A pot that remains after all hands are exhausted is unclaimed.

Return the number of cards won by each player.

Function

highCardPotScores(deck: int[], players: int) → int[]

Examples

Example 1

deck = [5,3,2,7]players = 2return = [2,2]

Player 0 wins the first two cards; player 1 wins the second round.

Example 2

deck = [8,8,2,9,1,3]players = 3return = [6,0,0]

The first-round high rank is tied, so all six cards are in the pot when player 0 uniquely reveals 9.

Example 3

deck = [4,4]players = 2return = [0,0]

The only round ties, so the final pot is unresolved and unclaimed.

Constraints

  • 2 <= players <= 52.
  • 0 <= deck.length <= 100000.
  • Each card rank is in [1, 13]; higher numbers beat lower numbers.

More Affirm problems

  • Group Transactions by HourONSITE INTERVIEW · Seen Nov 2026
  • Propagating Fraud DetectorPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Cross-Day User Trust ScoresPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
All Affirm interview questionsSee Affirm hiring insights
Saved
class Solution {
    public int[] highCardPotScores(int[] deck, int players) {
        // Write your solution here.
    }
}
Checking account…