FastPrepCoin With Randomly Marked Faces
Problems/Coin With Randomly Marked Faces

Coin With Randomly Marked Faces

Susquehanna International Group (SIG) logoSusquehanna International Group (SIG)● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An internship report posted in October 2020 describes a SIG technical phone round that followed the HR call. One of its two questions was a Bayes puzzle about a coin whose two sides are each marked heads or tails at random, half the time each. Given that one toss came up heads, it asks how likely heads is on the next toss.

The report gives one setting only and does not say whether the two sides are marked independently. Here, each face is marked on its own, independently of the others. These are inputs: the number of faces s (2 to 100, and a coin has 2), the chance p in whole percent (1 to 99) that a face is marked heads, the number of tosses seen t (up to 1000) and the number of heads h among them. Each toss shows a uniformly random face, and the function returns the chance that the next toss shows heads. The interview case (s = 2, p = 50, one toss, one head) is the first example. Answers within 10^-9 (absolute or relative) are accepted.

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

A special die has s faces; a coin is the case s = 2. Before the game, each face is marked H with probability p percent and T otherwise, independently. You cannot see the marks.

Each toss shows one of the s faces uniformly at random, independently of other tosses. You toss the die t times and see h tosses showing H and t - h showing T, in some order.

Return the probability that the next toss shows H.

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

Function

nextHeadsChance(s: int, p: int, t: int, h: int) → double

Examples

Example 1

s = 2p = 50t = 1h = 1return = 0.75

This is the interview coin. It has two H sides with chance 1/4, one H side with chance 1/2, and no H side with chance 1/4.

The first toss shows H with chance 1/4 × 1 + 1/2 × 1/2 = 1/2. Both tosses show H with chance 1/4 × 1 + 1/2 × 1/4 = 3/8. So the answer is (3/8) / (1/2) = 3/4.

Example 2

s = 2p = 50t = 2h = 2return = 0.8333333333333334

Two heads seen. The two-H coin gives this with chance 1/4 × 1 = 1/4 and the one-H coin with chance 1/2 × 1/4 = 1/8. The next toss is H with chance (1/4 × 1 + 1/8 × 1/2) / (1/4 + 1/8) = (5/16) / (3/8) = 5/6.

Example 3

s = 2p = 30t = 1h = 1return = 0.65

Each side is H with chance 0.3. The coin has one H side with chance 2 × 0.3 × 0.7 = 0.42 and two with chance 0.09. Seeing one H gives weights 0.42 × 1/2 = 0.21 and 0.09 × 1 = 0.09. The answer is (0.21 × 1/2 + 0.09 × 1) / 0.30 = 0.65.

Constraints

  • 2 <= s <= 100
  • 1 <= p <= 99
  • 1 <= t <= 1000
  • 0 <= h <= t

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

  • Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Logistic Regression with Gradient DescentYahoo · PHONE SCREENYahoo interview questions
  • Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Integer to English Words in USD and INR StylesVeeam · PHONE SCREEN
  • Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
  • Sum of Smallest Non-DivisorsThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions

Interview reports that mention this question

  • SIG Quant Research Intern Interviews: 60 Experiences

Susquehanna International Group (SIG) interview experiences

  • SIG Quant Researcher Experienced Hire Interviews: 11 Experiences
  • SIG Quant Researcher New Grad Interviews: 49 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 nextHeadsChance(int s, int p, int t, int h) {
        // Write your code here.
    }
}
Checking account…