FastPrepSame Number of Heads Game
Problems/Same Number of Heads Game

Same Number of Heads Game

Susquehanna International Group (SIG) logoSusquehanna International Group (SIG)● EasyNEW GRADINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Four reports from SIG quant phone screens in 2017 and 2018 ask about two people who each toss three coins and compare their head counts. Two new grad reports, from January 2017 and October 2018, frame it as a bet: the interviewer wins $2 when the counts match, you win $1 when they differ, and you must decide whether to play. The other two, from January 2018 (new grad) and February 2018 (internship, second round), ask only for the chance that the two counts match.

None of the reports gives an input format or a required precision. Here, the number of coins each person tosses and the two payoffs are inputs. The function returns your expected gain from one game, so a positive answer means the game is worth playing. The 3-coin, $2 and $1 game is the first example, and the chance of equal counts is the first step of the solution. Answers within 10^-9 (absolute or relative) are accepted.

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

You and the interviewer each toss n fair coins and count your heads.

  • If the two head counts are equal, you pay the interviewer equalPay dollars.
  • If they are different, the interviewer pays you differentWin dollars.

Return your expected gain from one game. A positive value means the game is worth playing; a negative value means you expect to lose money.

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

Function

expectedGain(n: int, equalPay: int, differentWin: int) → double

Examples

Example 1

n = 3equalPay = 2differentWin = 1return = 0.0625

This is the interview game. With 3 coins, one person gets 0, 1, 2 or 3 heads with chances 1/8, 3/8, 3/8 and 1/8.

The counts are equal when both get 0, both get 1, both get 2 or both get 3: (1/8)^2 + (3/8)^2 + (3/8)^2 + (1/8)^2 = 20/64 = 5/16.

Your expected gain is 1 × 11/16 - 2 × 5/16 = 1/16 = 0.0625. It is positive, so you should play.

Example 2

n = 1equalPay = 1differentWin = 1return = 0.0

With one coin each, the counts are equal half the time (both heads or both tails). You win 1 half the time and lose 1 half the time, so the expected gain is 0.

Example 3

n = 2equalPay = 3differentWin = 1return = -0.5

With 2 coins, one person gets 0, 1 or 2 heads with chances 1/4, 1/2 and 1/4. The counts are equal with chance 1/16 + 1/4 + 1/16 = 3/8.

The expected gain is 1 × 5/8 - 3 × 3/8 = -4/8 = -0.5, so this game is not worth playing.

Constraints

  • 1 <= n <= 1000
  • 1 <= equalPay, differentWin <= 1000

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

  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Revolver: Will the Next Shot Fire?Tower Research Capital · PHONE SCREEN
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Expected Fake-Name CollisionsMercor · PHONE SCREENMercor interview questions
  • Count Routes Through a City GridIMC Trading · PHONE SCREENIMC Trading interview questions
  • Extra Coin Win ProbabilityMicrosoft · PHONE SCREENMicrosoft interview questions
  • Count Clean Attendance LogsRippling · PHONE SCREENRippling interview questions
  • Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Subarray SumVisa · OAVisa 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 expectedGain(int n, int equalPay, int differentWin) {
        // Write your code here.
    }
}
Checking account…