Angle Between Clock Hands
Updated
Problem statement
An analog clock shows the time hour:minute. Both hands move smoothly: the minute hand goes all the way around once an hour, and the hour hand goes all the way around once every 12 hours, so it also moves a little as the minutes pass.
Return the smaller of the two angles between the hour hand and the minute hand, in degrees. The answer is always between 0 and 180.
Answers within 10-6 of the correct value are accepted.
Function
clockAngle(hour: int, minute: int) → doubleExamples
Example 1
hour = 9minute = 30return = 105.0The minute hand points at 30 minutes, which is 30 * 6 = 180 degrees from 12. The hour hand starts at 9, which is 270 degrees, and moves another 30 * 0.5 = 15 degrees in half an hour, so it is at 285 degrees. The gap is 285 - 180 = 105 degrees, which is already the smaller side.
Example 2
hour = 9minute = 20return = 160.0The minute hand is at 20 * 6 = 120 degrees. The hour hand is at 270 + 20 * 0.5 = 280 degrees. The gap one way is 280 - 120 = 160 degrees and the other way is 200 degrees, so the answer is 160.
Example 3
hour = 5minute = 20return = 40.0The minute hand is at 120 degrees. The hour hand is at 5 * 30 + 20 * 0.5 = 160 degrees. The gap is 40 degrees.
Example 4
hour = 12minute = 0return = 0.0At 12:00 both hands point straight up, so the angle is 0.
Example 5
hour = 3minute = 15return = 7.5The minute hand is at 15 * 6 = 90 degrees. The hour hand is at 3 * 30 + 15 * 0.5 = 97.5 degrees, a little past the 3. The gap is 7.5 degrees.
Constraints
1 <= hour <= 120 <= minute <= 59
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
- Route Length From Two CyclistsPHONE 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
- 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
- Catching the Bus to the MovieSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) 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
Interview reports that mention this question
- 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 TDO Earlier US Finals: 19 Experiences (Part 7 of 10)
- Jane Street TDOE Interviews: 165 Experiences (Part 1 of 10)
- Jane Street TDOE New Grad Interview Questions: 11 Experiences