FastPrepOne Number Is the Average of the Other Two
Problems/One Number Is the Average of the Other Two

One Number Is the Average of the Other Two

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

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two SIG quant intern reports ask for the chance that one of three numbers is the average of the other two. A report from December 2024 on a 30-minute HR screen chose the three numbers from 1 to 20. A report from June 2025 on a phone round for a systematic trading and quant research internship used three rolls of a six-sided die.

The first report does not say whether a number can be chosen twice. Here, distinct = true means three different numbers chosen at random from 1 to n, and distinct = false means three fair n-sided dice, which covers the second report. n goes up to 10^6, and answers within 10^-9 (absolute or relative) are accepted. Both interview cases are examples.

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

You get three numbers in one of two ways:

  • If distinct is true, you choose three different numbers from 1 to n. Every set of three is equally likely.
  • If distinct is false, you roll three fair dice with faces 1 to n. The rolls are independent, so numbers can repeat.

Return the probability that one of the three numbers is the average of the other two. For example, 4 is the average of 2 and 6, and 3 is the average of 3 and 3.

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

Function

meanOfOtherTwoProbability(n: int, distinct: boolean) → double

Examples

Example 1

n = 20distinct = truereturn = 0.07894736842105263

This is the first interview case. One number is the average of the other two exactly when the three numbers, sorted, have equal gaps: b - d, b, b + d.

A gap d fits 20 - 2d times inside 1 to 20, for d = 1 to 9. That gives 18 + 16 + ... + 2 = 90 good sets. There are C(20, 3) = 1140 sets in all, so the answer is 90 / 1140 = 3/38, about 0.0789.

Example 2

n = 6distinct = falsereturn = 0.19444444444444445

This is the second interview case: three six-sided dice, 6^3 = 216 equally likely rolls.

The 6 rolls with all three values equal work. Two equal values and one different never work. Sets with equal gaps inside 1 to 6 are 4 with gap 1 and 2 with gap 2, and each can be rolled in 6 orders, so they give 6 × 6 = 36 rolls. The answer is (6 + 36) / 216 = 7/36, about 0.1944.

Example 3

n = 5distinct = truereturn = 0.4

The good sets are {1, 2, 3}, {2, 3, 4}, {3, 4, 5} and {1, 3, 5}. There are C(5, 3) = 10 sets, so the answer is 4 / 10 = 0.4.

Constraints

  • 1 <= n <= 10^6
  • If distinct is true, then n >= 3.

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
  • Which Coin Pattern Shows Up FirstPHONE SCREEN · Seen May 2025
  • Random Points Inside One ArcPHONE SCREEN · Seen Jan 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 Researcher Experienced Hire Interviews: 11 Experiences
  • SIG Quant Research Intern Interviews: 60 Experiences
  • SIG Quant Researcher New Grad Interviews: 49 Experiences

Susquehanna International Group (SIG) interview 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 meanOfOtherTwoProbability(int n, boolean distinct) {
        // Write your code here.
    }
}
Checking account…