ML Interview Q Series: Calculating J, Q, K, A Hand Probability Using Combinatorial Methods
Browse all the Probability Interview Questions here.
You are dealt a hand of four cards from a well-shuffled deck of 52 cards. Specify an appropriate sample space and determine the probability that you receive the four cards J, Q, K, A in any order, with suit irrelevant.
Short Compact solution
An effective way to solve this problem is to regard the sample space as all possible 4-card subsets from the 52 cards, so there are (52 choose 4) equally likely outcomes. The four ranks J, Q, K, and A each have 4 suits available, and since suit is irrelevant, the number of favorable 4-card subsets (each containing exactly one J, one Q, one K, and one A) is (4 choose 1)(4 choose 1)(4 choose 1)(4 choose 1). Therefore, the probability is
which numerically equals about 9.46 x 10^-4.
One could also use an ordered perspective, where each outcome is one of the 52! permutations of the deck. The first four positions must be J, Q, K, A in some order. For each of these four ranks, there are 4 ways to choose the suit, giving 4^4 possibilities for the suits, and then 4! ways to arrange these four ranks in the first four positions. The remaining 48 cards can be in any order, so 48! ways. Thus the number of favorable permutations is 4^4 x 4! x 48!. Dividing by 52! gives the same probability, 9.46 x 10^-4.
Comprehensive Explanation
In probability problems like this, it is often helpful to specify clearly how the sample space is structured before counting the favorable events.
When the question focuses on being “dealt a hand of four cards,” it strongly suggests that the order in which we receive those four cards does not matter. Consequently, an unordered sample space (combinations of 4 cards from 52) is typically the most direct method of calculation. This approach counts the number of ways to choose subsets of size 4 out of 52, which is (52 choose 4). Because all 4-card subsets are equally likely, the probability of any specific 4-card subset is 1 / (52 choose 4).
In our specific situation, we want exactly one Jack, one Queen, one King, and one Ace. Each rank has 4 suits available, making 4 ways to choose the Jack, 4 ways to choose the Queen, 4 ways to choose the King, and 4 ways to choose the Ace. Multiplying these together yields 4 x 4 x 4 x 4 = 4^4, which accounts for the number of suit combinations that can form the set {J, Q, K, A}. That is why the favorable outcomes are (4 choose 1)(4 choose 1)(4 choose 1)(4 choose 1). Dividing by the total number of possible 4-card hands (52 choose 4) produces the probability.
An alternative approach is to treat the sample space as all permutations (52!) of the deck. In that case, we only look at which four cards appear in the first four positions. The count of favorable permutations is found by:
• 4^4 possible ways to choose the suits for J, Q, K, A. • 4! possible orders in which these four ranks can appear in the first four positions. • 48! ways to arrange the remaining 48 cards in the remaining positions.
Hence the probability from this ordered perspective is (4^4 x 4! x 48!) / 52!, which aligns with the unordered approach once the ratio is simplified.
This matching of results from two distinct sample spaces underscores that well-defined probability measures are consistent as long as we count both the sample space and the favorable outcomes in the same (ordered or unordered) manner.
Follow-up question: Why do we multiply by 4 four times for the suits rather than something else?
The reason is that each rank (Jack, Queen, King, Ace) can come in one of 4 suits. For instance, if we want exactly one Jack, there are 4 possible Jacks (club, diamond, heart, spade). The same reasoning applies to the Queen, King, and Ace. Multiplying 4 x 4 x 4 x 4 counts all ways of picking exactly one of each rank in any suit.
Follow-up question: What if the suits mattered (for instance, if we needed a specific suit combination like the Ace of Hearts, King of Clubs, etc.)?
In that scenario, the favorable cases would be strictly the specific suits you desire. For instance, if you demanded the Ace of Hearts, King of Clubs, Queen of Spades, Jack of Diamonds, there would be exactly 1 such hand. More generally, if you specified exactly which suits each rank must have, that set of four cards would be unique, so you would count only 1 favorable combination. The probability then becomes 1 / (52 choose 4) for that specific set of suits.
Follow-up question: How does this change if the question stated “in any order,” but now the order of drawing does matter?
If the order of drawing is relevant, you must decide whether the sample space is permutations of 52 cards or just permutations of 4 cards out of 52. In a scenario where you only draw 4 cards, we typically imagine them as an ordered draw from the deck. In that case, the total number of different 4-card sequences from 52 is 52P4 = 52 x 51 x 50 x 49. The favorable outcomes for drawing one J, one Q, one K, and one A in any order (still ignoring suits) would be 4^4 x 4! because each rank has 4 possible suits, and there are 4! ways to order the distinct ranks. Dividing those favorable outcomes by 52 x 51 x 50 x 49 would give the probability.
Follow-up question: Are there edge cases where these calculations become more complicated?
Edge cases include situations like multiple decks, incomplete decks, or draws with replacement. In multiple-deck scenarios, each rank might have more than 4 suits available. In draws with replacement, every time you draw a card and put it back, the events become independent, so the probability analysis changes considerably. Always ensure the assumptions align with how the deck is being used.
Follow-up question: How can we verify such probability computations in a simulation?
It is easy to write a simulation in Python. Shuffle a standard deck many times, deal 4 cards, and check how often we get the desired combination of {J, Q, K, A}. The observed frequency should converge near our computed probability. Here is a basic code outline:
import random
def estimate_probability(num_simulations=10_000_000):
ranks = ['J','Q','K','A']
deck = []
# Build the deck with suits for completeness
suits = ['♠','♥','♦','♣']
for r in range(2, 11):
for s in suits:
deck.append(str(r) + s)
face_cards = ['J','Q','K','A']
for f in face_cards:
for s in suits:
deck.append(f + s)
success_count = 0
for _ in range(num_simulations):
random.shuffle(deck)
hand = deck[:4]
# Check if these four cards are exactly one J, one Q, one K, one A (suits ignored)
ranks_in_hand = [card[:-1] for card in hand if card[:-1] in ranks]
# If we have exactly J, Q, K, A
if sorted(ranks_in_hand) == ['A','J','K','Q']:
success_count += 1
return success_count / num_simulations
print(estimate_probability(1000000))
Running this simulation with a sufficiently large number of repetitions should yield a value near 9.46e-4, confirming the theoretical analysis.
Below are additional follow-up questions
Suppose we are interested in the probability of drawing at least one Jack, Queen, King, and Ace among the four cards (i.e., duplicates allowed, but we need to see all four ranks at least once). How does that change the probability?
To address this, note that now we permit the four cards to contain duplicates of some ranks as long as each of the four ranks J, Q, K, A appears at least once. Because we only have four cards total, this scenario forces our four cards to be precisely {J, Q, K, A}, with no room for duplicates. Essentially, there's actually no difference between “exactly one of each” and “at least one of each” when the hand size is 4, because you can't exceed that count. The probability is then the same 4^4 / (52 choose 4). The subtlety: if we had a bigger hand (say 5 cards or more), “at least one of each” could include hands like {J, J, Q, K, A} or {Q, K, A, A, J}, etc. But in a 4-card hand, “at least one of each” collapses to “exactly one of each.”
A common pitfall here is to apply the inclusion-exclusion principle incorrectly, forgetting that in a 4-card hand it’s not possible to exceed those counts for each rank. For a hand size of 4, the sets “at least one Jack” and “at least one Queen” and so forth overlap trivially in this specific scenario.
How would the probability change if we had 6-card hands, and we wanted at least one J, one Q, one K, and one A in those 6 cards?
This question is far more involved because there are many ways to arrange at least one J, Q, K, A among 6 cards. One approach is to use the complement method:
• Total ways to choose any 6 cards: (52 choose 6). • Subtract ways in which we do NOT have at least one of each rank. So we exclude all hands missing at least one of J, Q, K, A:
No J, or no Q, or no K, or no A.
We would use the inclusion-exclusion principle to count precisely the number of hands that fail to have at least one J, or Q, or K, or A. The pitfall: it’s easy to double-count or incorrectly handle the overlaps if we don’t carefully track which ranks are missing. Another subtlety is that if multiple ranks are missing from the hand, each scenario must be accounted for in the inclusion-exclusion formula.
The inclusion-exclusion formula is typically written as:
• Let N be the total number of ways to draw 6 cards (52 choose 6). • Let N(J^c) be the number of 6-card hands that have no Jack. Similarly define N(Q^c), N(K^c), and N(A^c) for no Queen, no King, no Ace. • Then the number of hands that are missing at least one of the ranks is:
N(J^c) + N(Q^c) + N(K^c) + N(A^c)
[N(J^c ∩ Q^c) + N(J^c ∩ K^c) + ... ]
[N(J^c ∩ Q^c ∩ K^c) + ... ]
N(J^c ∩ Q^c ∩ K^c ∩ A^c)
The final answer becomes:
( # of hands that contain at least one J, Q, K, A ) = N - [the above sum].
If we decide that the probability question is specifically about the sequence in which cards appear (like a real-time dealing process), can we adopt a different counting method?
Yes, we can focus on permutations of 52 cards. However, to align properly, we must count both the sample space and the favorable outcomes in terms of permutations. The sample space is all possible 52! sequences. For an outcome to be favorable in the sense of “the first four drawn are J, Q, K, A in any suit, any order,” we count how many permutations start with those four distinct ranks in some arrangement of suits. As established, that’s 4^4 ways to pick suits, multiplied by 4! ways to order the four ranks, multiplied by 48! ways to permute the remainder of the deck. That yields 4^4 * 4! * 48! favorable permutations.
A subtle pitfall in real-time dealing is accidentally mixing up permutations and combinations. If you first say the total number of ways to choose 4 cards from 52 is (52 choose 4) but then count the favorable outcomes in an ordered fashion (like 4! times 4^4), you end up with a mismatch. Keeping the sample space definition consistent (all permutations or all combinations) is key.
What if the deck is not standard, for example, if there is a special deck of 60 cards (some added jokers or extra suits)? How do we handle that?
If we have a non-standard deck, the logic remains the same but we change the total number of ranks and suits accordingly. For instance, if the deck contains 60 cards and we still only define “J, Q, K, A” as special ranks, we need to know how many copies of each rank exist in this deck. If each rank still has 4 suits and the rest of the deck is non-traditional filler, then:
• The total sample space for a 4-card hand is (60 choose 4). • The number of favorable combinations for “exactly one J, one Q, one K, and one A” remains 4^4 if those four ranks each still have 4 suits.
Hence the probability becomes 4^4 / (60 choose 4).
A subtlety arises if the new deck includes extra suits or duplicate ranks. If there’s an extra suit (say 5 suits total, giving 5 possible Jacks, 5 possible Queens, etc.), then you’d have 5^4 favorable suit arrangements. The main pitfall is to carefully redefine the card distribution in the deck before performing the same counting approach.
What if we were asked for the probability of receiving exactly these four ranks AND these four specific suits (for instance, Ace of Spades, King of Hearts, Queen of Clubs, Jack of Diamonds)? How does that differ?
In that case, you’re no longer free to pick from among 4 suits for each rank. You want one specific card for the Ace, one specific card for the King, etc. So the number of favorable outcomes is 1. Exactly that one combination of four specified cards is allowed. The total sample space remains (52 choose 4).
Hence the probability = 1 / (52 choose 4).
This is an especially common pitfall: not recognizing the difference between “exactly these four ranks in any suit” and “exactly these four distinct cards.” The difference is the factor of 4^4 you lose when the suits are strictly fixed.
Could this probability shift if we consider the typical bridging rule that no one card can appear twice in a hand? (Sometimes novices ask about “drawing the same card again.”)
Yes, but in a standard physical deck, it’s impossible to draw the same exact card again without replacement. The deck physically contains only one copy of each unique rank-suit combination. If you consider a hypothetical “infinite deck” or “drawing with replacement,” the analysis changes. In drawing with replacement, each draw is from a full 52-card deck state. The probability of drawing a Jack, a Queen, a King, and an Ace in any order over four draws is computed differently, typically using Bernoulli trials logic or partition-based counting:
• Probability that the first draw is Jack, Queen, King, or Ace (any suit) is 16/52 = 4/13. • However, for “exactly one J, one Q, one K, and one A” in four draws with replacement, you have to consider all permutations of the ranks {J, Q, K, A} times (4/52)^4 for each specific pattern of suits.
A subtlety is that draws with replacement or partial replacement require separate enumerations. The pitfall is using standard combinatorial formulas that apply only to draws without replacement.
How would we use a direct probability multiplication approach for the original scenario without going to combinations?
If the 4-card hand is drawn without replacement and if order doesn’t matter, we could do this as a straightforward conditional probability approach (though it is typically more complicated for many ranks). For example:
Probability that the first card is one of the ranks J, Q, K, A: 16/52 = 4/13.
Then probability that the second card is one of the three remaining ranks, given the first was unique and different from that rank: 12/51.
Probability that the third card is one of the two remaining ranks, given the first two are distinct: 8/50.
Probability the fourth card is the last remaining rank, given the first three are distinct: 4/49.
You then multiply those together. But since the order among J, Q, K, A can occur in 4! different ways, you would multiply by 4! to capture every possible rank order. This approach yields:
(4/13) * (12/51) * (8/50) * (4/49) * 4!.
A subtlety here is that we must carefully handle the decreasing counts in the deck to avoid double-counting or missing certain rank-suit distributions. This approach should yield the same final answer but is prone to confusion if you skip the factor that accounts for all permutations of the four ranks.
In real card games, we often cut the deck or burn a card before dealing. Could that change the probability distribution?
Burning or cutting a deck is a uniform randomization technique but doesn’t change the overall distribution of which 4-card hand a player ultimately ends up with. Burning a card (removing one card unseen from the top of the deck) changes how we look at the distribution for partial draws, but as long as the deck is well-shuffled, every 4-card subset from the 52 cards is still equally likely to appear in any given 4-card distribution.
The key pitfall is to realize that removing random cards unseen from the deck does not bias which 4-card subset you receive. If someone sees the burned cards, that knowledge can affect conditional probabilities (because you know certain cards are no longer in the deck). In that scenario, you’d update your sample space based on that knowledge, thus shifting the probability.
If the question were about the probability that your 4-card hand is “just four face cards” (J, Q, K only—no Ace), how would that logic differ?
You’d repeat the same approach but focus on just the ranks J, Q, and K. Each rank has 4 suits, so there are 12 total face cards among the 52. For a 4-card hand to be “just face cards,” you’d be choosing all 4 from those 12 available J, Q, K face cards. Hence the number of favorable combinations is (12 choose 4). The total sample space is still (52 choose 4). So the probability is (12 choose 4) / (52 choose 4).
A common confusion arises around whether we’re talking about exactly face cards (only J, Q, K) versus face cards plus possibly Ace or other ranks. The wording “just four face cards” or “only face cards” excludes Aces, so you must be sure not to lump Aces into the set of face cards.
Could the probability be approximated by a hypergeometric distribution perspective, and what does that mean?
Yes, in fact when we talk about drawing without replacement from a finite population of 52 cards—some of which are “successes” (like J, Q, K, A) and the rest “failures” (the other ranks)—we are effectively dealing with a hypergeometric distribution. The probability of x successes in n draws from a population of size N with K successes overall is typically:
P(X = x) = [ (K choose x) * (N-K choose n-x ) ] / (N choose n).
In this case, “K successes overall” might be the total number of J, Q, K, A cards in the deck. However, we have four distinct ranks, which complicates direct application of a single hypergeometric. Instead, you’d define more complicated counting. The main pitfall is to incorrectly treat J, Q, K, A as a single category or to forget that each rank is unique. If the question was simply “probability of drawing 4 face cards out of 12 available face cards in a 52-card deck,” hypergeometric fits neatly. But “exactly one J, one Q, one K, and one A” is a slightly more specialized partition of the deck that can still be done with combinatorial arguments but is not a direct single-bucket hypergeometric scenario.
Is there a real-world application where the probability of drawing these specific ranks might matter?
In many trick-taking card games (e.g., Bridge, Hearts, Spades), certain ranks (like A, K, Q, J) carry special scoring or trick-taking power. Sometimes a particular combination of high cards might significantly influence the strategy or outcome. While the probability of having “J, Q, K, A in your opening four cards” might be rare, it can be relevant if a game has special bonuses for holding these four ranks.
In real tournaments, the pitfall is conflating house rules or partial knowledge (like seeing some cards played or discarding) with your unconditional probability. If other players have already revealed certain cards, the probability of you drawing the J, Q, K, A changes dramatically because you update your prior distribution. In short, context matters, and real-world applications often come down to conditional probabilities once some information is revealed.