When to Accept a Doubled Bet
Updated
Problem statement
You are in a bet where you currently stand to lose stake dollars. Your opponent doubles (or more generally raises) the bet to raised dollars, and you must choose:
- Decline: you lose
stakedollars and the game ends. - Accept: the game continues. You win
raiseddollars with probabilitypand loseraiseddollars otherwise.
Return the smallest p for which accepting is at least as good as declining on average.
Your answer is accepted if its absolute error or its relative error is at most 10^-9.
Function
minWinChance(stake: int, raised: int) → doubleExamples
Example 1
stake = 10raised = 20return = 0.25This is the interview case: the bet is doubled from $10 to $20.
Accepting is worth 20p - 20(1 - p) = 40p - 20 on average, and declining is worth -10. Accepting is at least as good when 40p - 20 >= -10, that is, p >= 1/4.
Example 2
stake = 10raised = 30return = 0.3333333333333333The bet is tripled. Accepting is worth 60p - 30, declining -10, so accept when p >= 20/60 = 1/3.
Example 3
stake = 5raised = 6return = 0.08333333333333333A small raise. Accepting is worth 12p - 6, declining -5, so accept when p >= 1/12. A small raise is worth calling even as a big underdog.
Constraints
1 <= stake < raised <= 10^6
More Susquehanna International Group (SIG) Phone Screen questions
- Dice Sum That Is a Multiple of mPHONE SCREEN · Seen Nov 2026
- Find Median from Data StreamPHONE SCREEN · Seen Nov 2026
- Painting Arcs to Nearest Neighbors on a CirclePHONE SCREEN · Seen Sep 2026
- Filter Movies by Inclusive Year RangePHONE SCREEN · Seen Jul 2026
- Best Single Reroll for Five DicePHONE SCREEN · Seen Feb 2026
- Catching the Bus to the MoviePHONE SCREEN · Seen Jan 2026
- Two Dice Summing to a TargetPHONE SCREEN · Seen Jan 2026
- Median of Uniform Draws in an IntervalPHONE SCREEN · Seen Oct 2025
- One Number Is the Average of the Other TwoPHONE SCREEN · Seen Jun 2025
- Which Coin Pattern Shows Up FirstPHONE SCREEN · Seen May 2025
Similar questions at other companies
- Pressure Chamber Linear InterpolationSpaceX · PHONE SCREENSpaceX interview questions
- Integer Square Root with Error ChecksBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
- Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Convex Function MinimizationUber · PHONE SCREENUber interview questions
- Square Root with Newton IterationGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
- Minimum of a Convex FunctionRippling · PHONE SCREENRippling interview questions
- Minimum Full Glasses for an Exact Water VolumeMarshall Wace · PHONE SCREENMarshall Wace interview questions
- Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
- Percentile and Boundary QueriesDatadog · PHONE SCREENDatadog interview questions