FastPrepSum of Two Uniform Numbers in a Range
Problems/Sum of Two Uniform Numbers in a Range

Sum of Two Uniform Numbers in a Range

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

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from January 2025 on a 30-minute first-round HR phone screen for a SIG quant research internship says one question asked for the chance that X + Y lands in [1, 2] when X is uniform on [0, 1] and Y is uniform on [0, 2]. The candidate suggested working from the density of X + Y.

Here, the two widths a and b and the range ends lo and hi are whole-number inputs (widths up to 10^6, 0 <= lo <= hi <= a + b). The two numbers are independent, and answers within 10^-9 (absolute or relative) are accepted. The interview case is the first example.

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

X is a random real number chosen uniformly between 0 and a. Y is a random real number chosen uniformly between 0 and b. The two choices are independent.

Return the probability that lo <= X + Y <= hi.

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

Function

sumInRangeProbability(a: int, b: int, lo: int, hi: int) → double

Examples

Example 1

a = 1b = 2lo = 1hi = 2return = 0.5

This is the interview case. Picture every pair (X, Y) as a point in a 1 by 2 rectangle, which has area 2.

For any X between 0 and 1, the good values of Y run from 1 - X to 2 - X. Both ends stay inside [0, 2], so that range always has length 1. The good area is 1 × 1 = 1, and the answer is 1 / 2 = 0.5.

Example 2

a = 1b = 1lo = 0hi = 1return = 0.5

In a 1 by 1 square, X + Y <= 1 is the triangle below the diagonal, with area 1/2. So the answer is 0.5.

Example 3

a = 4b = 2lo = 3hi = 5return = 0.4375

The rectangle is 4 by 2, area 8. The area where X + Y <= 5 is 7.5: the triangle with legs 5 has area 12.5, and we cut off the pieces past the sides, which have areas 0.5 and 4.5. The area where X + Y <= 3 is 4.5 - 0.5 = 4.

The answer is (7.5 - 4) / 8 = 7/16 = 0.4375.

Constraints

  • 1 <= a, b <= 10^6
  • 0 <= lo <= hi <= a + b

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

  • Range of a Third CorrelationTower Research Capital · PHONE SCREEN
  • Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Union Area of Two RectanglesDocuSign · PHONE SCREENDocuSign interview questions
  • Intersection of Two RectanglesFigma · PHONE SCREENFigma interview questions
  • Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions
  • Max Points on a LineUber · PHONE SCREENUber interview questions
  • Count Axis-Aligned and Rotated SquaresGoogle · PHONE SCREENGoogle interview questions
  • Best-Fit Plane Normal from 3D PointsThe Voleon Group · PHONE SCREEN
  • Meeting of Points Moving Toward Initial SuccessorsThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Maximum Visible DronesAnduril · PHONE SCREENAnduril 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 sumInRangeProbability(int a, int b, int lo, int hi) {
        // Write your code here.
    }
}
Checking account…