FastPrepWait for the Bus: Run or Walk
Problems/Wait for the Bus: Run or Walk

Wait for the Bus: Run or Walk

Jane Street logoJane Street● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in five Jane Street interview reports dated 2025 to 2026, for trading desk operations roles, in problem-solving or online interview rounds. Two reports give a bus or train every 20 minutes, a 5 minute run and a 10 minute walk to the stop, and ask for the expected wait; one of them also lets you mix running and walking. One report compares a train every 10 minutes with walking, and the interviewer kept changing the setup. Two only name a bus waiting-time or waiting-time paradox question.

We turned it into a function that takes the bus interval and both travel times. The random time you leave home, the exact mixed rule (check when the next bus leaves, walk if that is in time, otherwise run if that is in time, otherwise walk to the bus after), returning all three plans, the limits and the 10^-6 tolerance are our own choices, and every example except the first is ours.

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

A bus leaves your stop exactly every interval minutes. You leave home at a random moment, so the time until the next bus leaves is equally likely to be any value between 0 and interval minutes. Getting to the stop takes runTime minutes if you run and walkTime minutes if you walk. If you reach the stop at the moment a bus leaves, you still catch it.

Compare three plans:

  1. Always walk.
  2. Always run.
  3. Mixed: before you set off you check when the next bus leaves. If walking gets you there in time, you walk. Otherwise, if running gets you there in time, you run. Otherwise you walk and take the bus after that one.

Return an array of three numbers: the expected number of minutes you spend waiting at the stop under plan 1, plan 2 and plan 3, in that order.

Answers within 10-6 of the correct values are accepted.

Function

expectedWaits(interval: int, runTime: int, walkTime: int) → double[]

Examples

Example 1

interval = 20runTime = 5walkTime = 10return = [10.0,10.0,6.25]

Walking or running alone, you reach the stop at a random point in the bus cycle, so the average wait is half of 20, which is 10 minutes. With the mixed plan, let u be the minutes until the next bus when you leave. If u is between 10 and 20 you walk and wait u - 10, which is 5 on average, half of the time. If u is between 5 and 10 you run and wait u - 5, which is 2.5 on average, a quarter of the time. If u is below 5 you walk to the following bus and wait u + 10, which is 12.5 on average, a quarter of the time. The mixed average is 0.5 * 5 + 0.25 * 2.5 + 0.25 * 12.5 = 6.25.

Example 2

interval = 10runTime = 5walkTime = 10return = [5.0,5.0,2.5]

The single plans wait 5 minutes on average. For the mixed plan, walking takes 10 minutes but the next bus always leaves in less than 10 minutes, so walking never catches it. If u is at least 5 you run and wait u - 5, which is 2.5 on average. If u is below 5 you walk to the following bus and wait u, also 2.5 on average. The mixed average is 2.5.

Example 3

interval = 12runTime = 4walkTime = 7return = [6.0,6.0,3.75]

The single plans wait 6 minutes on average. For the mixed plan: u from 7 to 12 (chance 5/12) waits 2.5 on average, u from 4 to 7 (chance 3/12) waits 1.5, and u below 4 (chance 4/12) waits u + 5, which is 7 on average. The total is (5 * 2.5 + 3 * 1.5 + 4 * 7) / 12 = 45 / 12 = 3.75.

Example 4

interval = 15runTime = 3walkTime = 3return = [7.5,7.5,7.5]

Running is no faster than walking here, so the mixed plan never changes anything. Every plan reaches the stop at a random point in a 15 minute cycle and waits 7.5 minutes on average.

Example 5

interval = 30runTime = 6walkTime = 30return = [15.0,15.0,10.2]

The single plans wait 15 minutes on average. Walking takes the whole cycle, so the mixed plan runs whenever u is at least 6 (chance 24/30, average wait 12) and otherwise walks to the following bus (chance 6/30, average wait 3). The total is (24 * 12 + 6 * 3) / 30 = 306 / 30 = 10.2.

Constraints

  • 1 <= runTime <= walkTime <= interval <= 104

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

  • 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

  • Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
  • Jane Street TDOE UK Coding Round: 15 Experiences (Part 3 of 10)
  • Jane Street TDOE Interviews: 165 Experiences (Part 1 of 10)

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)
All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public double[] expectedWaits(int interval, int runTime, int walkTime) {
      // Write your code here.
    }
}
Checking account…