FastPrepChance a Hand of Cards Multiplies to More Than a Threshold
Problems/Chance a Hand of Cards Multiplies to More Than a Threshold

Chance a Hand of Cards Multiplies to More Than a Threshold

Optiver logoOptiver● MediumFULLTIMEOA

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: One 2026 write-up from an Optiver full-time quant research OA is mostly a set of probability exercises for practice; we built this problem from the card exercise in that set.

In it, three of six cards numbered 1 to 6 are taken at random, none of them twice, and the question wants the chance that the three numbers multiply to more than 30. The post gives no answer.

Our choices: the number of cards, the hand size and the threshold are inputs (up to 50 cards and a threshold up to 10^6; the report uses 6 cards, 3 drawn and 30). We take "more than" strictly, so a hand whose product equals the threshold is not counted; in the reported case two hands give exactly 30, and counting them would turn 2/5 into 1/2. We return an exact fraction in lowest terms instead of a decimal: with 50 cards and 9 drawn there are 2,505,433,700 hands, so one hand changes the chance by about 4 x 10^-10, less than a usual decimal tolerance of 10^-9. Example 1 matches the report; the limits and the other examples were picked by us.

Our version is about 80% the same as the reported question.

There are n cards with the labels 1, 2, ..., n, one card for each label. You draw k of them without replacement, and all possible hands of k cards are equally likely.

Multiply the labels you drew. Return the chance that this product is strictly greater than threshold, as an exact fraction [numerator, denominator] in lowest terms with denominator > 0. A chance of 0 is written [0, 1] and a chance of 1 is written [1, 1].

Function

probabilityProductExceeds(n: int, k: int, threshold: int) → long[]

Examples

Example 1

n = 6k = 3threshold = 30return = [2,5]

There are C(6, 3) = 20 hands. Eight of them multiply to more than 30: {2, 3, 6} = 36, {2, 4, 5} = 40, {2, 4, 6} = 48, {2, 5, 6} = 60, {3, 4, 5} = 60, {3, 4, 6} = 72, {3, 5, 6} = 90 and {4, 5, 6} = 120. The hands {1, 5, 6} and {2, 3, 5} give exactly 30, which is not more than 30. So the chance is 8/20 = 2/5.

Example 2

n = 6k = 2threshold = 6return = [3,5]

There are C(6, 2) = 15 pairs. Six of them multiply to 6 or less: {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6} and {2, 3} (the last two both give exactly 6). The other 9 pairs give more than 6, so the chance is 9/15 = 3/5.

Example 3

n = 5k = 5threshold = 120return = [0,1]

The only possible hand holds all five cards, and 1 × 2 × 3 × 4 × 5 = 120. That equals the threshold instead of passing it, so the chance is 0, returned as [0, 1].

Constraints

  • 1 <= k <= n <= 50
  • 1 <= threshold <= 10^6
  • Both numbers of the answer fit in a signed 64-bit integer.

More Optiver Online Assessment questions

  • Chance a Die Game Balance Reaches ZeroOA · Seen Dec 2026
  • Chance a Sum of Random Draws Has a Given Number of DigitsOA · Seen Dec 2026
  • Expected Draws to Remove All Green CountersOA · Seen Dec 2026
  • Expected Profit of a Doubling Betting SystemOA · Seen Dec 2026
  • Expected Steps Until a Random Walk Gets Far From ZeroOA · Seen Dec 2026
  • Rolling Until One Face's Own Total Passes a ThresholdOA · Seen Dec 2026
  • Two Ranked Teams Meeting in a Random BracketOA · Seen Dec 2026
  • Overheat Prevention ControllerOA · Seen Nov 2026
  • Power Cell BankOA · Seen Nov 2026
  • Count Straight-Line Word Occurrences in a GridOA · Seen Sep 2026

Similar questions at other companies

  • Frog Paths Without Long RunsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
  • Count Lucky TicketsThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
  • Jump Game with Prime-Step RuleUber · OAUber interview questions
  • Count Shipment SchedulesMorgan Stanley · OAMorgan Stanley interview questions
  • Unique Paths Through a GridPeopleStrong · OAPeopleStrong interview questions
  • Get Minimum OperationsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Jump Game with Prime-3 StepsAgoda · OAAgoda interview questions
  • Find Encrypted NumberAmazon · OA
  • Prime StringSnowflake · OASnowflake interview questions

Optiver interview experiences

  • Optiver SWE Intern OA: CPU Temperature Simulation: 1 Experience
  • Optiver Trading Intern Market-Making Games: 1 Experience
  • Optiver Quant Trader Intern Technical Interview: 1 Experience
  • Optiver SWE Intern System Design Interview: 15 Experiences
All Optiver interview questionsSee Optiver hiring insights
Saved
class Solution {
    public long[] probabilityProductExceeds(int n, int k, int threshold) {
        // Write your code here.
    }
}
Checking account…