Probability Two People Meet
Updated
Problem statement
Two friends, A and B, plan to meet at the same spot. Each of them arrives at a moment chosen uniformly at random within the same window of windowMinutes minutes, independently of the other.
After arriving, A waits up to waitA minutes for B and then leaves. B waits up to waitB minutes for A and then leaves. They meet if one of them arrives while the other is still waiting. A wait that runs past the end of the window is allowed.
Return the probability that they meet. Answers within 10-6 of the correct value are accepted.
Function
meetProbability(windowMinutes: int, waitA: int, waitB: int) → doubleExamples
Example 1
windowMinutes = 60waitA = 15waitB = 15return = 0.4375Draw A's arrival on one axis and B's on the other, both from 0 to 60. They miss when B comes more than 15 minutes after A, or A comes more than 15 minutes after B. Each of those two corners is a right triangle with legs 45, so together they cover 45 * 45 = 2025 of the 3600 square. The chance of meeting is 1 - 2025/3600 = 7/16 = 0.4375.
Example 2
windowMinutes = 60waitA = 10waitB = 20return = 0.4305555555555556B comes more than 10 minutes after A in a triangle with legs 50, area 1250. A comes more than 20 minutes after B in a triangle with legs 40, area 800. The chance of meeting is 1 - 2050/3600 = 31/72, about 0.430556.
Example 3
windowMinutes = 30waitA = 45waitB = 0return = 0.5A waits longer than the whole window, so A is still there whenever B comes later. B does not wait at all, so they miss whenever B comes first. Each order is equally likely, so the answer is 0.5.
Constraints
1 <= windowMinutes <= 1090 <= waitA, waitB <= 109
More Jane Street Phone Screen questions
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
- Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
- Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
- Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
- Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
- Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
- Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
- Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
- Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Painting Arcs to Nearest Neighbors on a CircleSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
- Meeting of Points Moving Toward Initial SuccessorsThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
- Point Inside a TriangleSambaNova Systems · PHONE SCREEN · ONSITE INTERVIEWSambaNova Systems interview questions
- Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions
- Range of a Third CorrelationTower Research Capital · PHONE SCREEN
- Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Max Points on a LineUber · PHONE SCREENUber interview questions
- Count Axis-Aligned and Rotated SquaresGoogle · PHONE SCREENGoogle interview questions
- Union Area of Two RectanglesDocuSign · PHONE SCREENDocuSign interview questions
- Best-Fit Plane Normal from 3D PointsThe Voleon Group · PHONE SCREEN
Interview reports that mention this question
Jane Street interview experiences
- Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)
- Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
- Jane Street TDO Phone Math Round: 26 Experiences (Part 9 of 10)
- Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
- Jane Street TDO Excel and VBA Test: 23 Experiences (Part 8 of 10)