FastPrepGuessing Ball Colors One by One
Problems/Guessing Ball Colors One by One

Guessing Ball Colors One by One

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

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three reports from SIG technical phone rounds describe a guessing game with a box of 2 red and 2 blue balls. An internship report posted in March 2019 asks for the expected number of right guesses when you guess each ball's color before taking it, and gives 17/6. A new grad report posted in February 2024 pays $1 for each right guess and asks how much you would pay to play. A new grad report posted in January 2018 names the same box and asks about the chance of guessing right, without more detail.

Here, the numbers of red and blue balls (0 to 1000 each) are inputs. The balls come out in uniformly random order without being put back, and you see each ball after it comes out. The function returns the expected number of right guesses under the best strategy, which is also the price that makes the $1-per-guess game break even. The 2 red, 2 blue box is the first example. Answers within 10^-9 (absolute or relative) are accepted.

Our version is about 85% the same as the reported questions.

A box holds red red balls and blue blue balls. The balls are taken out one at a time, in a uniformly random order, and are not put back.

Before each ball is taken out, you guess its color. You see every ball after it comes out, so you always know how many balls of each color are left. You score 1 point for each correct guess.

Return the expected number of correct guesses when you guess as well as possible.

Your answer is accepted if its absolute error or its relative error is at most 10^-9.

Function

expectedCorrectGuesses(red: int, blue: int) → double

Examples

Example 1

red = 2blue = 2return = 2.8333333333333335

This is the interview box. With 2 of each left, any guess is right with chance 1/2. Then one color has 2 balls left and the other has 1; guess the color with 2, which is right with chance 2/3.

If that guess was right, 1 of each is left: a guess right with chance 1/2, then the last ball is known. If it was wrong (chance 1/3), both remaining balls have the same color and both guesses are right. The total is 1/2 + 2/3 + 2/3 × (1/2 + 1) + 1/3 × 2 = 17/6, about 2.8333.

Example 2

red = 1blue = 1return = 1.5

The first guess is right with chance 1/2. After that you know the color of the last ball, so the second guess is always right. The answer is 1.5.

Example 3

red = 3blue = 1return = 3.25

Keep guessing red while red is the larger color. As the editorial shows, guessing the larger color gives exactly 3 right guesses on the draws where the counts are not tied, whatever the order.

The counts are tied (1 of each left) only when the blue ball is one of the last two, chance 1/2, and that tie adds half a point on average. The answer is 3 + 1/2 × 1/2 = 3.25.

Constraints

  • 0 <= red <= 1000
  • 0 <= blue <= 1000
  • red + blue >= 1

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

  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • 3D Grid Diagonal Walk ProbabilityApple · PHONE SCREENApple interview questions
  • Coin Game From The EndsTekion · PHONE SCREENTekion interview questions
  • Starting Value with the Longest Collatz ChainZipRecruiter · PHONE SCREENZipRecruiter interview questions
  • Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
  • Maximum-Product Subarray with an Empty ChoiceAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Count Staircase WaysGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • New 21 Game ProbabilityUiPath · PHONE SCREEN
  • Count Stepping Numbers In RangeAmazon · PHONE SCREEN

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 expectedCorrectGuesses(int red, int blue) {
        // Write your code here.
    }
}
Checking account…