FastPrepBest Single Reroll for Five Dice
Problems/Best Single Reroll for Five Dice

Best Single Reroll for Five Dice

Susquehanna International Group (SIG) logoSusquehanna International Group (SIG)● MediumINTERNNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In a recruiter phone screen for a quant research internship, the candidate had five dice with faces 1 to 9 showing 2, 2, 4, 6 and 7. They could roll one die again and won with a full house (three matching dice and a matching pair) or with three values in a row plus a pair. They were asked which die to roll, then compared two other hands. Two other reports mention the same dice question, one of them with faces 1 to 10.

The reports do not give exact rules for every hand. Here, the dice have k faces with k from 1 to 100. The starting hand never wins. Five of a kind does not count as a full house. The pair may repeat a value from the run. Runs do not wrap from k back to 1. You return the best chance of winning instead of naming the die. The follow-up questions and the number of rolls needed are covered in the editorial and are not tested. The interview case is the first example.

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

You have five dice. Each die has k faces numbered 1 to k, and each face comes up with probability 1/k. The array dice holds the five values showing now.

A hand of five values wins if you can split the five dice into a group of three and a pair. The two dice in the pair must show the same value. The group of three must be one of these:

  • Three of a kind: all three show the same value, and that value is different from the pair's value.
  • A run: the three show three values in a row, x, x + 1 and x + 2. The pair may repeat one of these values.

For example, [2,2,2,4,4], [2,2,5,6,7] and [3,4,4,4,5] all win. In the last one, the run is 3,4,5 and the pair is the other two 4s. [5,5,5,5,5] and [1,2,3,4,5] do not win. Runs do not wrap around from k back to 1.

The current hand does not win. You must choose exactly one die and roll it again. The other four dice keep their values, and the rerolled die can show any face, including its old value.

Return the best probability of winning after the reroll, taken over all five choices of which die to reroll. Your answer is accepted if its absolute error or its relative error is at most 10^-9.

Function

bestRerollWinProbability(k: int, dice: int[]) → double

Examples

Example 1

k = 9dice = [2,2,4,6,7]return = 0.2222222222222222

This is the interview case. Rerolling the 4 wins if it shows 5 (run 5,6,7 plus the pair of 2s) or 8 (run 6,7,8 plus the pair of 2s), so that chance is 2/9.

Rerolling the 7 wins only with 5 (run 4,5,6 plus the pair of 2s), which is 1/9. Rerolling the 6 or either 2 never wins. The best choice is the 4, and the answer is 2/9, about 0.2222.

Example 2

k = 9dice = [2,2,2,4,6]return = 0.2222222222222222

Rerolling the 6 wins with 3 (run 2,3,4 plus a pair of 2s) or with 4 (three 2s and a pair of 4s), so that chance is 2/9.

Rerolling the 4 wins only with 6, and rerolling a 2 wins only with 5 (run 4,5,6 plus a pair of 2s). Each of those is 1/9. The answer is 2/9.

Example 3

k = 9dice = [2,4,4,4,5]return = 0.3333333333333333

Rerolling the 2 wins with 3 (run 3,4,5 plus a pair of 4s), with 5 (three 4s and a pair of 5s) or with 6 (run 4,5,6 plus a pair of 4s). That chance is 3/9.

Rerolling the 5 wins with 2 or 3, which is only 2/9. Rerolling a 4 never wins. The answer is 3/9 = 1/3.

Constraints

  • 1 <= k <= 100
  • dice.length == 5
  • 1 <= dice[i] <= k
  • The hand in dice does not win.

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
  • 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
  • Random Points Inside One ArcPHONE SCREEN · Seen Jan 2025

Similar questions at other companies

  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Monthly Calendar with Custom Week StartStripe · PHONE SCREENStripe interview questions
  • Fractional Share Inventory FlatteningRobinhood · PHONE SCREEN · ONSITE INTERVIEWRobinhood interview questions
  • Logistic Regression DiagnosticsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
  • Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
  • Cumulative No-Intercept Regression BetasCitadel · PHONE SCREENCitadel interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
  • Automation Pipeline, Part 2: Stage WorkersPlaid · PHONE SCREENPlaid interview questions

Interview reports that mention this question

  • SIG Quant Research Intern Interviews: 60 Experiences
  • SIG Quant Researcher New Grad Interviews: 49 Experiences

Susquehanna International Group (SIG) interview experiences

  • SIG Quant Researcher Experienced Hire Interviews: 11 Experiences
  • SIG Quant Researcher Intern Interviews: 1 Experience
  • SIG Quant Second-Round Tech Screen: 1 Experience
All Susquehanna International Group (SIG) interview questionsSee Susquehanna International Group (SIG) hiring insights
Saved
class Solution {
    public double bestRerollWinProbability(int k, int[] dice) {
        // Write your code here.
    }
}
Checking account…