Route Length From Two Cyclists
Updated
Problem statement
Two cyclists leave point A at the same moment and ride the same road to point B, each at a constant speed. One rides at fastSpeed kilometres per hour and the other at slowSpeed kilometres per hour.
The slower cyclist reaches B exactly gapMinutes minutes after the faster one. Return the distance from A to B in kilometres.
Answers within 10-6 of the correct value are accepted.
Function
routeDistance(fastSpeed: int, slowSpeed: int, gapMinutes: int) → doubleExamples
Example 1
fastSpeed = 15slowSpeed = 10gapMinutes = 60return = 30.0The route is 30 kilometres. At 15 kilometres per hour it takes 2 hours, and at 10 kilometres per hour it takes 3 hours, which is 60 minutes longer.
Example 2
fastSpeed = 20slowSpeed = 12gapMinutes = 40return = 20.0The route is 20 kilometres. The faster rider needs 60 minutes and the slower one needs 100 minutes, a gap of 40 minutes.
Example 3
fastSpeed = 7slowSpeed = 3gapMinutes = 25return = 2.1875The route is 2.1875 kilometres. The faster rider needs 18.75 minutes and the slower one needs 43.75 minutes, a gap of 25 minutes. The answer does not have to be a whole number.
Constraints
1 <= slowSpeed < fastSpeed <= 1001 <= gapMinutes <= 1440
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
- Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Painted Cube: Count and RollPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
- Pressure Chamber Linear InterpolationSpaceX · PHONE SCREENSpaceX interview questions
- When to Accept a Doubled BetSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
- Integer Square Root with Error ChecksBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
- Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Convex Function MinimizationUber · PHONE SCREENUber interview questions
- Square Root with Newton IterationGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
- Minimum of a Convex FunctionRippling · PHONE SCREENRippling interview questions
- Minimum Full Glasses for an Exact Water VolumeMarshall Wace · PHONE SCREENMarshall Wace interview questions